2013-08-08 3 views
0

여러 모듈을 가진 maven 프로젝트를 빌드하려고합니다. 그래서 나는 그것들이 pom.xml에 주어진 순서대로 만들어지기를 기대하지만, 빌드 할 때 모듈의 순서가 pom.xml 파일에 언급 된 순서와 같지 않다는 것을 알 수있다. 그 이유가 무엇일까요?Maven build out of order

내 메이븐 버전 : 아파치 메이븐 3.0.4

답변

1

Maven은 의존성에 따라 순서를 결정한다. 그래서 3 개의 서브 모듈이 있다면 : A, B, C, 각 서브 모듈에 들어가서 종속성을 명시 적으로 만들어야합니다. 예를 들어, B의 pom.xml로 가서 A와 C에 의존한다고 선언하면, maven은 임의의 순서로 A와 C를 빌드하고 마지막에 B를 빌드합니다.

1

부모 pom 파일에서 언급 한 순서는 모듈간에 종속성 충돌이없는 경우에도 관련됩니다. 즉, 목록에있는 모듈이 위에 있고 모듈이 그 아래에있는 모듈에 종속 된 경우 이 경우 POM 파일에 언급 된 순서는 사용되지 않을 것이고, Maven은 그의 두뇌를 사용하고 먼저 다른 모듈이 필요로하는 모든 모듈을 빌드 할 것입니다.

빌드 주문에 대한 자세한 내용은 questionMaven Spec을 동일하게보십시오. 사양에서

:

Reactor Sorting 

Because modules within a multi-module build can depend on each other, 
it is important that The reactor sorts all the projects in a way that 
guarantees any project is built before it is required. 

The following relationships are honoured when sorting projects: 

    1. project dependency on another module in the build 
    2. plugin declaration where the plugin is another modules in the build 
    3. plugin dependency on another module in the build 
    4. build extension declaration on another module in the build 
    5. the order declared in the modules element (if no other rule applies) 

Note that only "instantiated" references are used - dependencyManagement 
and pluginManagement elements will not cause a change to the reactor 
sort order.