我有一个maven项目,其子项目有自己的子项目,配置如下:
parent pom.xml listing sub-projects as modules
sub-project 1 pom.xml listing child-projects as modules
child project 1-1 pom.xml
child project 1-2 pom.xml
sub-project 2 pom.xml listing child-projects as modules
child project 2-1 pom.xml
child project 2-2 pom.xml
child project 2-3 pom.xml
sub-project 3 pom.xml listing child-projects as modules
child project 3-1 pom.xml
子项目3取决于子项目2的输出,而子项目2的输出又取决于子项目1的输出。
我想要完成的是连续运行每个子项目,并且并行运行所有子项目。所需的执行顺序如下:
Build starts
sub-project 1 execution starts
all child projects of sub-project 1 are started in their own threads
all child projects of sub-project 1 finish execution
sub-project 1 execution ends
sub-project 2 execution starts
all child projects of sub-project 2 are started in their own threads
all child projects of sub-project 2 finish execution
sub-project 2 execution ends
sub-project 3 execution starts
all child projects of sub-project 3 are started in their own threads
all child projects of sub-project 3 finish execution
sub-project 3 execution ends
Build process completes
对maven使用-T命令行参数只是一次开始执行所有项目,如下所示:
Build starts
Start sub-project 1
start sub-project 2
Start sub-project 3
Start child project n...
由于子项目之间的依赖关系而失败。
有没有办法规定如何在maven中使用线程的细粒度方法?
答案 0 :(得分:0)
我有同样的用法,并且无法使用-T选项实现它,因为它只是告诉maven使用多线程来构建项目,并且如果一个子项目依赖于其他项目,那么它就是一个子项目。尚未构建,显然它会失败,而不是等待(IMO是正确的事情,否则它可能会造成死锁并导致系统挂起)。
请参阅https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3以获取有关maven中并行构建的更多信息。