메이븐이 만들어 내는 site 문서를 열어보면 프로젝트 설명이라든가  등등에서 한글이 깨져서 나오기도 하는데

site 문서의 html 소스를 까보면 한글이 깨지는 이유를 알게된다.

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

html 문서의 charset은 maven-site-plugin의 outputEncoding 설정을 통해 바꿀 수 있다.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-site-plugin</artifactId>
    <version>2.0-beta-6</version>
    <configuration>
     <outputEncoding>euc-kr</outputEncoding>
    </configuration>
</plugin>

그러나 이걸로도 한글이 깨지는 걸 피할 수 없는 리포트가 있는데 StatSCM 리포트가 그렇다.
stat-scm 플러그인은 소스버전관리 저장소의 활동내역을 통계 리포트로 생성하는 플러그인이다.
   <plugin>
    <groupId>net.sf</groupId>
    <artifactId>stat-scm</artifactId>
    <version>1.2.0</version>
   </plugin>

여러가지 멋진 통계그래프를 만들어주는 간지나는 플러그인이다. 다만 아쉬운 것이 CVS접속 계정이 한글인 경우
site 인코딩을 euc-kr로 하든 utf-8로 하든 뭔 지랄을 해도 한글이 깨진다는 것이다.



근데 재밋게도 차트안에 들어가는 한글은 안깨지고 잘 나온다. 거참 희한하다.

ps. 위에 실명이 나와서 좀 거시기한데.. 설마 이 글을 보지는 않겠지?
Posted by 에코지오
,

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 에코지오
,
아직 원격 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 에코지오
,