2014-09-04 4 views
1

추가 빌드 단계가 필요한 라이브러리 (RootBeer)를 사용 중입니다. JAR 파일을 만든 후 RootBeer JAR을 매개 변수로 사용하여 RootBeer JAR을 실행하여 최종 RootBeer 지원 JAR 파일을 만들어야합니다.메이븐 사용자 정의 포장

java -jar rootbeer.jar myjar.jar myjar-final.jar 

내가가 저를 가능하게 할 메이븐의 메커니즘이 있는지 알고 싶습니다 내 항아리 myjar.jar 경우

예는이 내가 RootBeer과 최종 가공품 myjar-final.jar을 만들 필요가 어떻게 이런 식으로 유물을 만들어라.

지금은 그루비 스크립트와 gmaven-plugin를 사용하고 있지만, 이것은 너무 해키 느낌, 그리고 내가 다른 프로젝트에서 메이븐 의존성으로 인한 인공물을 사용할 수없는 확신 :

<plugin> 
    <groupId>org.codehaus.groovy.maven</groupId> 
    <artifactId>gmaven-plugin</artifactId> 
    <executions> 
     <execution> 
     <id>groovy-magic</id> 
     <phase>package</phase> 
     <goals> 
      <goal>execute</goal> 
     </goals> 
     <configuration> 
      <source> 
       println """java -jar target/rootbeer-1.2.0.jar target/myjar.jar target/myjar-final.jar""" 
        .execute().in.eachLine { 
         line -> println line 
       } 
      </source> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

제안 사항이 있으십니까?

답변

3

Groovy로 구현 한 마지막 단계를 실행하기 위해 exec-maven-plugin을 사용할 수 있습니다. build-helper-maven-plugin을 추가해야 Maven에 보완 아티팩트를 추가하여 나머지 아티팩트와 함께 배포 할 수 있습니다.

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.3.2</version> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>java</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <!-- The main class of rootbeer.jar --> 
       <mainClass>org.trifort.rootbeer.entry.Main</mainClass> 
       <!-- by setting equal source and target jar names, the main artefact is 
       replaced with the one built in the final step, which is exactly what I need. --> 
       <arguments> 
        <argument>${project.build.directory}/${project.artifactId}.jar</argument> 
        <argument>${project.build.directory}/${project.artifactId}.jar</argument> 
        <argument>-nodoubles</argument> 
       </arguments> 
      </configuration> 
     </plugin> 
+0

답변 해 주셔서 감사합니다. 기본 인공물을 대체 할 실행 파일을 설정할 수 있기 때문에'build-helper-plugin'을 사용할 필요가 없었습니다. –

관련 문제