Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

java - How to make maven build of child module with parent module?

I have multiple modules in my project and they are dependent on each other either directly or transitively. When I maven build ?Project A? some where ?Project D? gets build automatically.

Project A > Project B  > Project C > Project D

where > means Project B depends on Project A

?Project D? pom snipeet is:

<project xmlns="...">
    <modelVersion>4.0.0</modelVersion>  
    <groupId>com.myProduct</groupId>
    <artifactId>build-MyProjectD</artifactId>
    <name>MyProjectD</name>
    ........
</project>

As building ?Project A? automatically build ?Project B?, as per my understanding to make this happen somewhere build-MyProjectD should be added as dependency in one of these projects Project A > Project B > Project C but I did not find any reference of string build-MyProjectD under poms of these projects.

Any idea how is there any other way to make build of child module (in this case ?Project D?) without having child artifactId presence in upstream project?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to create an aggregator project. See the link for more information on the aggregation concept.

Basically, you create a parent project containing several "modules". When building the parent, the modules automatically gets built as well.

If you declare dependencies between the modules, Maven will automatically build the different modules in a correct order so that if ?Project A? depends on ?Project B?, ?Project B? is built first and then ?Project A? is built so that its artifact is available for the building of the second artifact.

See also this question from the Maven's FAQ.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...