2011-09-28 4 views
0

여러 Maven 모듈에서 단일 실행 파일 jar를 빌드하는 데 문제가 있습니다. 그래서 여기 상황입니다 : 나는 3 개의 maven 모듈을 가지고 있습니다 : app -> persistence -> domain. 나는 부모 pom.xml도 가지고있다. 그래서여러 개의 Maven 모듈에서 실행 가능한 jar 빌드하기

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-assembly-plugin</artifactId> 
    <configuration> 
     <archive> 
      <manifest> 
       <mainClass>com.toys.app.Service</mainClass> 
      </manifest> 
     </archive> 
     <descriptorRefs> 
      <descriptorRef>jar-with-dependencies</descriptorRef> 
     </descriptorRefs> 
    </configuration> 
</plugin> 

내가 (parent.pom 및 응용 프로그램, 지속성 및 도메인 받는다는 모듈을 포함하는) 부모 치어 디렉토리에 명령 줄에서 입력 한 명령 : MVN 조립 : 조립 나는이 부모 치어 받는다는 조립 플러그인에 추가

[INFO] ------------------------------------------------------------------------ 
[INFO] Building persistence 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (default-cli) @ persistence --- 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Summary: 
[INFO] 
[INFO] parent ..................................... SUCCESS [3.147s] 
[INFO] domain ............................................ SUCCESS [4.765s] 
[INFO] persistence ....................................... FAILURE [0.570s] 
[INFO] app ............................................... SKIPPED 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 9.287s 
[INFO] Finished at: Wed Sep 28 12:30:26 CEST 2011 
[INFO] Final Memory: 6M/81M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (default-cli) on project persistence: Failed to create assembly: Failed to resolve dependencies for project: com.toys:persistence:jar:1.0-SNAPSHOT: Missing: 
[ERROR] ---------- 
[ERROR] 1) com.toys:domain:jar:1.0-SNAPSHOT 
[ERROR] 
[ERROR] Try downloading the file manually from the project website. 
[ERROR] 
[ERROR] Then, install it using the command: 
[ERROR] mvn install:install-file -DgroupId=com.toys -DartifactId=domain -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file 
[ERROR] 
[ERROR] Alternatively, if you host your own repository you can deploy the file there: 
[ERROR] mvn deploy:deploy-file -DgroupId=com.toys -DartifactId=domain -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] 
[ERROR] 
[ERROR] Path to dependency: 
[ERROR] 1) com.toys:persistence:jar:1.0-SNAPSHOT 
[ERROR] 2) com.toys:domain:jar:1.0-SNAPSHOT 
[ERROR] 
[ERROR] ---------- 
[ERROR] 1 required artifact is missing. 
[ERROR] 
[ERROR] for artifact: 
[ERROR] com.toys:persistence:jar:1.0-SNAPSHOT 
[ERROR] 
[ERROR] from the specified remote repositories: 
[ERROR] central (http://repo1.maven.org/maven2, releases=true, snapshots=false) 
[ERROR] -> [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 :persistence 

다른 모든 받는다는 수명주기가 잘 작동 : 그것은 나의 다음 오류를 준! 누구든지 나를 도울 수 있습니까? 나는 앱, 지속성, 도메인 프로젝트와 같은 수준에 프로젝트 '유통'을 추가 제안

 <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
       <archive> 
        <manifest> 
        <mainClass>com.toys.app.Service</mainClass> 
        </manifest> 
       </archive>    
       <descriptorRef>jar-with-dependencies</descriptorRef>     
      </configuration> 
      <executions> 
       <execution> 
        <id>make-jar-with-dependencies</id> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
+0

이러한 종속성의 범위는 무엇입니까? – Thomas

+0

기본값은 "compile"입니다. –

답변

0

봅니다 실행 단계를 추가 할 수 있습니다.

<project> 

    <artifactId>distribution</artifactId> 
    <packaging>pom</packaging> 

    <parent> 
    ... 
    </parent> 

    <dependencies> 
    <dependency> 
     <groupId>${project.groupId}</groupId> 
     <artifactId>app</artifactId> 
     <version>${project.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>${project.groupId}</groupId> 
     <artifactId>persistence</artifactId> 
     <version>${project.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>${project.groupId}</groupId> 
     <artifactId>domain</artifactId> 
     <version>${project.version}</version> 
     <scope>runtime</scope> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
      <archive> 
       <manifest> 
       <mainClass>com.toys.app.Service</mainClass> 
       </manifest> 
      </archive>    
      <descriptorRef>jar-with-dependencies</descriptorRef>     
      </configuration> 
      <executions> 
      <execution> 
       <id>make-jar-with-dependencies</id> 
       <phase>package</phase> 
       <goals> 
       <goal>single</goal> 
       </goals> 
      </execution> 
      </executions> 
     <plugin> 
    </plugins> 
    </build> 

</project> 

반응기 POM에서 자체 프로젝트로 이동 한 후에도 유사한 문제가 발생했지만 두통이 없었습니다.

또한 원자로 프로젝트에 '분배'모듈을 추가하는 것을 잊지 마십시오.

+0

작동하지만,이 jar 파일을 추출 할 때 내가 작성한 패키지와 클래스가 없습니다! –

+0

이 빌드를 어떻게 실행합니까? 첫째, 각 서브 모듈에 'install'을 실행하십시오. 원하는 모듈에서 '패키지'목표를 실행하십시오. –

+0

각 모듈에 "install"을 실행하려고 시도했지만 도메인 모듈이 성공했지만 도메인 모듈에 의존하는 지속성 모듈에서 오류가 발생했습니다. ** [ERROR] 프로젝트 지속성에서 목표를 실행하지 못했습니다 : 종속성을 해결할 수 없습니다 프로젝트의 경우 com.toys:persistence:jar:1.0-SNAPSHOT : [com.toys:domain:jar:1.0-SNAPSHOT (compile), org.springframework : spring-tx : jar : 3.0.5.RELEASE에 대한 종속성을 수집하는 데 실패했습니다. (컴파일), ...] : com.toys:domain:jar:1.0-SNAPSHOT에 대한 이슈 설명자를 읽지 못했습니다 : 이슈를 찾을 수 없습니다 com.toys : parent : pom : 1.0 - SNAPSHOT -> [Help 1] ** –

0

:

관련 문제