2016-07-26 2 views
1

어셈블리 플러그인에서이 작업을 수행하고 많은 설명자를 시도했지만 작동하지 않는 것으로 알고 있습니다. 오류 메시지의 의미를 이해할 수 없습니다.maven 다중 모듈 프로젝트에 종속성이있는 jar 빌드

프로젝트 아키텍처 : STI는는 애그리 게이터 (aggregator) 프로젝트입니다

---sti (parent project containing a pom.xml) 
-----sti-any23 
-----sti-common-util 
-----sti-kbsearch 
-----sti-websearch 
-----sti-main 

. 모듈 sti-main은 다른 모든 네 개의 모듈에 따라 다릅니다.

은 부모 프로젝트의 pom.xml 보이는 같은 :

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>....</groupId> 
    <artifactId>sti</artifactId> 
    <version>1.0alpha</version> 
    <packaging>pom</packaging> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <maven-install-plugin.version>2.5.2</maven-install-plugin.version> 
     <maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version> 
     <maven-source-plugin.version>2.2.1</maven-source-plugin.version> 
     <exec-maven-plugin.version>1.4.0</exec-maven-plugin.version> 
     <maven-shade-plugin.version>2.3</maven-shade-plugin.version> 
    </properties>   
    <modules> 
     <module>sti-any23</module> 
     <module>sti-common-util</module> 
     <module>sti-kbsearch</module> 
     <module>sti-websearch</module> 
     <module>sti-main</module> 
    </modules>    
    <build> 
     <defaultGoal>install</defaultGoal> 
     <plugins>     
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-source-plugin</artifactId> 
       <version>${maven-source-plugin.version}</version> 
       <executions> 
        <execution> 
         <id>attach-sources</id> 
         <phase>verify</phase> 
         <goals> 
          <goal>jar</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>exec-maven-plugin</artifactId> 
       <version>${exec-maven-plugin.version}</version> 
       <configuration> 
        <mainClass/> 
       </configuration> 
      </plugin> 
      <plugin> 
       <inherited>true</inherited> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>${maven-compiler-plugin.version}</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
        <encoding>UTF-8</encoding> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <version>2.5.4</version> 
       <configuration> 
        <descriptorRefs> 
         <descriptorRef>jar-with-dependencies</descriptorRef> 
        </descriptorRefs> 
       </configuration> 
       <executions> 
        <execution> 
         <id>make-assembly</id> 
         <phase>package</phase> 
         <goals> 
          <goal>single</goal> 
         </goals> 
         <configuration> 
          <descriptors> 
           <descriptor>config/maven-assembly/module.xml</descriptor> 
          </descriptors> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

     </plugins> 
    </build> 
</project> 

기술자는 '설정/받는다는 - 조립 /을 Module.xml'는 다음과 같습니다

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> 
    <!-- TODO: a jarjar format would be better --> 
    <id>alljars</id> 
    <formats> 
    <format>jar</format> 
    </formats> 
    <includeBaseDirectory>false</includeBaseDirectory> 
    <dependencySets> 
    <dependencySet> 
     <outputDirectory>/</outputDirectory> 
     <useProjectArtifact>true</useProjectArtifact> 
     <unpack>true</unpack> 
     <scope>runtime</scope> 
    </dependencySet> 
    </dependencySets> 
</assembly> 

내가 오류 :

[WARNING] Cannot include project artifact: uk.ac.shef.dcs:sti:pom:1.0alpha; it doesn't have an associated file or directory. 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Summary: 
[INFO] 
[INFO] sti-any23 .......................................... SUCCESS [ 1.709 s] 
[INFO] sti-common-util .................................... SUCCESS [ 0.728 s] 
[INFO] sti-kbsearch ....................................... SUCCESS [ 1.213 s] 
[INFO] sti-websearch ...................................... SUCCESS [ 0.433 s] 
[INFO] sti-main ........................................... SUCCESS [ 2.855 s] 
[INFO] sti ................................................ FAILURE [ 0.389 s] 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 7.839 s 
[INFO] Finished at: 2016-07-26T19:50:53+01:00 
[INFO] Final Memory: 75M/505M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.4:single (make-assembly) on project sti: Failed to create assembly: Error creating assembly archive alljars: You must set at least one file. -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command 
[ERROR] mvn <goals> -rf :sti 

또한 많은 다른 설명자를 stackoverflow에서 찾았지만 둘 다 작동하지 않았습니다. 나는 몇 가지 기본 개념을 잘못 이해 했음에 틀림 없다고 생각하지만, 그것이 무엇인지 모른다.

의견을 보내주십시오. 감사합니다

답변

1

부모 프로젝트 내에 어셈블리 플러그인 사용법을 본 적이 없습니다. 상위 모듈의 크기는 <packaging>pom</packaging>입니다. 출력은 단지 pom 파일입니다. POM 외에도 실제 아티팩트를 출력하는 것은 이치에 맞지 않습니다.

제 생각에는 어셈블리 플러그인 선언을 하위 모듈로 이동하고이 하위 모듈의 일부로 만 실행해야합니다. 다른 모든 프로젝트는이 모듈에 대한 종속성으로 선언되어야하며이 시점부터 어셈블리를 빌드해야합니다.

+0

예. 또는 어셈블리를 만드는 것이 목표 인 새 모듈을 만들 수도 있습니다. 부모로부터'maven-assembly-plugin '을 사용하면 모듈 바이너리를 어셈블 할 수 있습니다 (http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/module-binary-inclusion- simple.html)하지만 분명히 기존 모듈이나 전용 모듈 내부에서이를 수행하는 것을 선호합니다. – Tunaki

+0

감사합니다. I는 삭제 '모듈'블록 '용기'에 'packaing'를 변경 및 블록 ' 1.0alpha STI 메인 uk.ac.shef.dcs'를 추가했다. 트릭을하는 것 같습니다. 이 올바른지? – Ziqi

+0

나는 @Tunaki에 동의한다. 나는 또한 작업을 수행하는 전용 모듈을 선호한다. –

관련 문제