2011-06-10 7 views
3

maven 빌드를 수행하는 동안 기존 jar/zip 파일의 항목을 대체하고 싶습니다. 이것을 달성하는 가장 쉬운 방법은 무엇입니까? 고맙습니다.Maven - jar 파일을 대체하십시오.

+0

아마 당신은 당신의 문제가 무엇인지 설명하는 것과 같은 더 자세한 정보를 제공해야합니다. 누가 이것을 알고 싶다면 해결책을 찾을 필요가 없습니다. – Raghuram

답변

7

내가 좋아하는 태스크 종류는 내가 좋아하는 개미 기능을 제공하는 maven-antrun-plugin입니다.

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.6</version> 
    <executions> 
     <execution> 
     <id>repack</id> 
     <phase>compile</phase> 
     <goals> 
      <goal>run</goal> 
     </goals> 
     <configuration> 
      <target> 
      <!-- note that here we reference previously declared dependency --> 
      <unzip src="${org.apache:common-util:jar}" dest="${project.build.directory}/tmp"/> 
      <!-- now do what you need to any of unpacked files under target/tmp/ --> 
      <zip basedir="${project.build.directory}/tmp" destfile="${project.build.directory}/common-util-modified.jar"/> 
      <!-- now the modified jar is available --> 
      </target> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

을하지만 기억 - 로컬 저장소에서 파일을 수정하지 않습니다 -이 예제에서 ${org.apache:common-util:jar} 가리키는 :

이처럼 사용할 수 있습니다. 그렇게하면 동일한 컴퓨터에있는 모든 프로젝트의 추가 빌드에 영향을 미칩니다 (동일한 로컬 저장소에 대해).

이러한 빌드는 다른 컴퓨터에서도 재현 할 수 없거나 재현하기 어렵습니다.

+1

http://docs.oracle.com/javase/tutorial/deployment/jar/update.html에 설명 된대로'jar uf jar-file input-file (s) '명령과 함께'antrun' 플러그인을 사용하는 것을 선호합니다. – Vince

관련 문제