2014-10-21 2 views
0
<plugin> 
     <artifactId>maven-assembly-plugin</artifactId> 
     <configuration> 
      <descriptorRefs> 
       <descriptorRef>jar-with-dependencies</descriptorRef> 
      </descriptorRefs> 
      <archive> 
       <manifest> 
        <mainClass>com.company.Main</mainClass> 
       </manifest> 
      </archive> 
     </configuration> 
     <executions> 
      <execution> 
       <phase>package</phase> 
       <goals> 
        <goal>single</goal> 
       </goals> 
      </execution> 
     </executions> 
    </plugin> 

문제는 프로젝트에 보관하고 싶은 일부 로컬 종속성입니다.로컬 종속성과 함께 maven-assembly-plugin 사용

나는과 같이 pom.xml에서 그들을 정의 :

<dependency> 
     <groupId>groupid</groupId> 
     <artifactId>local</artifactId> 
     <version>1.1</version> 
     <scope>system</scope> 
     <systemPath>${basedir}/lib/local-utilities-1.1.jar</systemPath> 
    </dependency> 

을 지금은 maven-assembly-plugin 팩 자동의 repo에서 다운로드 가능한 경우에만 의존 ... 즉, 그 지역의 항아리에서 사용할 수 있기 때문에 아마 전체를 포장 할 때 패키지 단계가 아닌 단계 컴파일 (올바른?).

이 플러그인에 종속성도 포함시킬 수 있습니까? <scope>package 및 기타 단계로 변경하려고 시도했지만 Maven에서 허용하지 않는 것 같습니다.

+0

참조 : 이 http://stackoverflow.com/questions/2588502/maven-assembly-plugin-doesnt-add-dependencies-with-system-scope 저장소 관리자를 사용하여 시작 또는 [사용 – Grzesuav

+0

스티븐 Collony의 plugin] (https://github.com/stephenc/non-maven-jar-maven-plugin)이 있는데, 이것은'system scope'보다 나은 해결책입니다. – khmarbaise

답변

1

패키지 관리자가 포함 할 수 있도록 이러한 종속성을 "수동으로"복사해야합니다.

<build> 
     <pluginManagement>  
      <plugins> 
       <!-- Ignore/Execute plugin execution --> 
       <plugin> 
        <groupId>org.eclipse.m2e</groupId> 
        <artifactId>lifecycle-mapping</artifactId> 
        <version>1.0.0</version> 
        <configuration> 
         <lifecycleMappingMetadata> 
          <pluginExecutions> 
           <!-- copy-dependency plugin --> 
           <pluginExecution> 
            <pluginExecutionFilter> 
             <groupId>org.apache.maven.plugins</groupId> 
             <artifactId>maven-dependency-plugin</artifactId> 
             <versionRange>[1.0.0,)</versionRange> 
             <goals> 
              <goal>copy-dependencies</goal> 
             </goals> 
            </pluginExecutionFilter> 
            <action> 
             <ignore /> 
            </action> 
           </pluginExecution> 
          </pluginExecutions> 
         </lifecycleMappingMetadata> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 

     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-dependency-plugin</artifactId> 
        <version>2.4</version> 
       <executions> 
          <execution> 
          <phase>package</phase> 
         <goals> 
          <goal>copy-dependencies</goal> 
         </goals> 
        </execution> 

       </executions> 
       <configuration> 
        <outputDirectory>${project.build.directory}</outputDirectory> 
       </configuration> 
      </plugin> 

      <plugin> 
       <!-- creates one single JAR, run: mvn assembly:single | mvn install --> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>single</goal> 
         </goals> 
          </execution> 
       </executions> 
       <configuration> 
        <archive> 
         <manifest> 
          <mainClass>${mainClass}</mainClass> 
         </manifest> 
        </archive> 
        <descriptorRefs> 
         <descriptorRef>jar-with-dependencies</descriptorRef> 
        </descriptorRefs> 
       </configuration> 
      </plugin> 

     </plugins> 

    </build> 
관련 문제