maven antrun plugin을 통해 ant의 scp 타스크를 이용하여 파일을 전송하기 위해 딸랑 jsch 라이브러리만 의존성에 추가하면 scp 타스크가 없다고 에러가 떨어진다. 

   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     ... ...
    </executions>
    <dependencies>
     <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jsch</artifactId>
      <version>0.1.38</version>
     </dependency>
    </dependencies>
   </plugin>

jsch 뿐 아리나 ant-jsch 아티팩트도 antrun 플러그인 의존성에 추가해야 한다. maven을 통하지 않고 순전히 scp작업을 build.xml에 정의해서 ant로 실행하면 jsch 라이브러리만 ant에 추가해주면 된다. ant-jsch.jar는 이미 ant에 포함되어 있기 때문이다.

   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <id>remote-exploded-deploy-scp</id>
      <phase>integration-test</phase>
      <goals>
       <goal>run</goal>
      </goals>
      <configuration>
       <tasks>
        <scp todir="user:user@myserver:/home/user/temp" trust="true">
         <fileset dir="${project.basedir}/temp" />
        </scp>
       </tasks>
      </configuration>
     </execution>
     <execution>
      <id>server-restart</id>
      <phase>integration-test</phase>
      <goals>
       <goal>run</goal>
      </goals>
      <configuration>
       <tasks>
        <sshexec host="myserver" username="user" password="user" trust="true"
         timeout="20000" failonerror="false" command="sh restart.sh" />
       </tasks>
      </configuration>
     </execution>
    </executions>
    <dependencies>
     <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-jsch</artifactId>
      <version>1.7.1</version>
     </dependency>
     <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jsch</artifactId>
      <version>0.1.38</version>
     </dependency>
    </dependencies>
   </plugin>

마찬가지로 ftp 타스크를 쓸 때도 commons-net 뿐 아니라 ant-commons-net도 추가해주어야 한다.

   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <id>remote-exploded-deploy-ftp</id>
      <phase>integration-test</phase>
      <goals>
       <goal>run</goal>
      </goals>
      <configuration>
       <tasks>
        <ftp server="myserver" remotedir="/home/user/temp" userid="user"
         password="user">
         <fileset dir="${project.basedir}/temp" />
        </ftp>
       </tasks>
      </configuration>
     </execution>
    </executions>
    <dependencies>
     <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-commons-net</artifactId>
      <version>1.7.1</version>
     </dependency>
     <dependency>
      <groupId>commons-net</groupId>
      <artifactId>commons-net</artifactId>
      <version>1.4.1</version>
     </dependency>
    </dependencies>
   </plugin>
Posted by 에코지오
,
pom.xml에서 모든 의존 라이브러리가 system 스코프로 설정된 경우 
site 문서 생성시 null point 에러가 발생한다.

c:\>mvn site
... ....
[INFO] Generating "Dependencies" report.
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NullPointerException
        at org.apache.maven.report.projectinfo.dependencies.renderer.DependenciesRenderer.printArtifactsLocations(DependenciesRenderer.java:1182)

메이븐의 프로젝트 기본정보 리포트 생성 플러그인(maven-project-info-reports-plugin)이 만들어 내는 리포트 중에 dependencies 리포트가  있는데 이 리포트를 생성하면서 에러가 나는 것이다.

http://jira.codehaus.org/browse/MPIR-131

해결 방법은 2가지가 있다.

1. system 스코프가 아닌 라이브러리를 하나 이상 추가한다.
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.2</version>
  </dependency>

2. site 문서에서 dependencies 리포트를 아싸리 빼버린다.
 <reporting>
  <plugins>
   <plugin>
    <artifactId>maven-project-info-reports-plugin</artifactId>
    <reportSets>
     <reportSet>
      <reports>
       <report>index</report>
       <report>summary</report>
       <report>project-team</report>
       <!-- 모든 dependency의 scope가 system인 경우 error 발생 -->
       <!-- report>dependencies</report -->
      </reports>
     </reportSet>
    </reportSets>
   </plugin>
....
....


Posted by 에코지오
,

지금 있는 프로젝트에서 package-info.java 라는 것을 처음 보게 되었는데,
이클립스에서 컴파일하면 잘되는 소스인데 메이븐으로는 컴파일오류가 발생하였다.

"package annotations should be in file package-info.java"

컴파일 환경은 윈도우 + jdk 1.5 + maven-compiler-plugin 2.0.2 조합이었고,
메이븐 컴파일러는 외부 jdk를 쓰기 위해 fork=true로 설정했다.

   <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <fork>true</fork>
     <executable>C:/bea/jdk150_11/bin/javac.exe</executable>
    </configuration>
   </plugin>

구글링해보니 maven-compiler 플러그인이 소스 경로에 디렉토리 구분자로 / 사용하는데 원인이 있었다.

http://jira.codehaus.org/browse/MCOMPILER-71

이건 jdk의 버그라고 생각할 수도 있다. 하여간에,

윈도우 환경에서 이 오류를 해결하는 방법은?

1. fork하지 않고 컴파일
2. cygwin을 통해 컴파일



Posted by 에코지오
,
메이븐으로 컴파일하다가 java.nio.BufferOverflowException 에러가 발생하는 경우가 있다.

구글링해보니 여러가지 원인이 있을 수 있는데 메모리가 부족한 경우에도 발생할 수 있다는 얘기도 있으나
대부분은 운영체제의 기본 인코딩과 다른 인코딩의 소스를 컴파일할 때나 (소스안에 주어진 인코딩으로 인식불가능한 캐릭터가 들어있다든가 하는 식으로) 소스가 깨진 경우 에러가 발생한다고 나온다.

결론은 소스의 정확한 인코딩을 메이븐 maven-compiler-plugin에 알려줘야 한다는 것이다. 요렇게 설정하거나

   <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
     <encoding>UTF-8</encoding>
    </configuration>
   </plugin>

<maven.compiler.encoding>UTF-8</maven.compiler.encoding> 프로퍼티를 통해 인코딩을 설정할 수 있다.
Posted by 에코지오
,

Maven으로 많은 소스를 컴파일하거나 사이트 문서 생성시 메모리가 많이 필요한데,
기본 메모리로는 메모리 부족 오류가 날 수 있다.

Maven홈/bin/mvn.bat 파일에서 MAVEN_OPTS에 -Xmx 옵션을 주어 적당히 메모리를 늘려준다.

set MAVEN_OPTS=-Xmx512m

Hudson을 통해 Maven을 실행한다면 빌드Job 선택 후 Configure > Build > Advanced… > MAVEN_OPTS 필드에 아래처럼 설정한다.


Posted by 에코지오
,
아직 원격 maven 저장소에 등록돼있지 않은 jar 파일을 pom.xml의 의존성에 추가하는
방법 중 하나로 jar 파일을 로컬 저장소에 설치하는 방법이 있다.

로컬 설치는 install:install-file goal을 이용하면 되는데 사용법은 다음과 같은 곳에서 확인할 수 있다.

http://maven.apache.org/plugins/maven-install-plugin/usage.html
http://maven.apache.org/general.html#importing-jars
http://maven.apache.org/pom.html#Dependencies

근데 웃긴건 mvn install:install-file -Dfile=your-artifact-1.0.jar  이런식으로 -Dfile 파라미터만 주면
마치 로컬에 jar가 설치될 것처럼 사이트에서 설명하고 있다는 것이다. pom 레퍼런스 사이트에는
file, artifact, group, version 파라미터를 주어서 설치하는 예제가 나와있기도 하다.

그러나 막상 실행해보면 이런식으로 에러가 떨어진다.(maven 2.0.9에서 테스트해봄)
[INFO] [install:install-file]
[INFO] ----------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ----------------------------------------------------------------
[INFO] Missing group, artifact, version, or packaging information

결국 artifact, group, version, packaging 옵션은 선택이 아니라 필수라는 걸 알게된다. 이제 아래처럼 packaging, file, groupId, artifactId, version 옵션을 필수로 입력해야 제대로 설치된다.
mvn install:install-file -Dpackaging=jar -Dfile=non-maven-proj.jar -DgroupId=some.group -DartifactId=non-maven-proj -Dversion=1.x -DgeneratePom=true

그리고 기왕이면 generatePom=true로 설정하여 m2eclipse 플러그인에서 설치된 jar 파일이 검색이 되도록 pom 파일을 함께 생성하는 것이 좋다.(pom 파일이 없으면 m2eclipse에서는 검색이 안된다)
Posted by 에코지오
,
AppFuse-light 버전이 너무 간단한거 같아 AppFuse 2.x를 받아서
소스 좀 볼 요량으로 appfuse.org를 갔는데 웬걸 다운로드 링크가 없다... ㅠㅠ

설치 자체가 Maven을 이용하는 것으로 바뀌었다. 헐... 메이븐 설치도 안했는뎅!~

우선 Spring-MVC Basic 아키타입을 받고,

mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=com.mycompany.app -DartifactId=myproject

myproject 디렉토리로 이동해서 mvn 날린후 아래 명령으로 전체 소스를 받는다.

mvn appfuse:full-source
혹시 받다가 URL 관련 에러날 경우에는 apache-maven-2.0.8\conf\settings.xml 를 열고,
로컬 메이븐 저장소 경로를 디폴트 경로(C:\Documents and Settings\Administrator\.m2\repository)에서
스페이스 없는 경로로 바꾸면 된다.

<settings>
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ~/.m2/repository
  -->
  <localRepository>D:\MavenRepository</localRepository>

* 자바지기님의 메이븐 강좌도 참고하자.
Maven 강좌 7 - Maven을 이용하여 Appfuse 프로젝트 생성하기

Posted by 에코지오
,