简体   繁体   English

如何在Maven 2中更快地构建多模块项目?

[英]How to build multimodule project faster in maven 2?

I have a multimodule maven project in which there are 7 several modules. 我有一个多模块Maven项目,其中有7个模块。 Every time I modify a code in one of the module and run mvn clean install, it takes some time and I think there might be a way to reduce time of builds since I only change small part of the code and I think it effects only limited area. 每次我在其中一个模块中修改代码并运行mvn clean install时,都会花费一些时间,并且我认为可能有一种减少构建时间的方法,因为我只更改了一小部分代码,并且我认为这样做的效果有限区域。 So I guess instead of running "mvn clean install" there is a better command option. 所以我想不是运行“ mvn clean install”,而是一个更好的命令选项。

I am using maven 2.x. 我正在使用Maven2.x。

Any better ideas? 还有更好的主意吗?

TIA TIA

The "clean" goal deletes all the target folders which contain the compiled classes, it should not be necessary to run that goal as part of the modify-compile-test cycle that you may run many times per day. “干净”目标将删除所有包含已编译类的目标文件夹,因此不必将该目标作为每天可能多次运行的Modify-Compile-Test循环的一部分来运行。 In your case most of the time is probably spent re-compiling all the Java files, due to the class files having been deleted during the "clean" goal. 在您的情况下,大多数时间都可能花费在重新编译所有Java文件上,因为在“干净”目标期间类文件已被删除。 So I would use "mvn install" when testing local changes, and "mvn clean install" only periodically, like when you get other developers changes to integrate with, or when testing immediately before a release. 因此,我将在测试本地更改时使用“ mvn install”,并且仅定期使用“ mvn clean install”,例如当您与其他开发人员进行更改集成时,或者在发布之前进行测试时。

I would suggest to use the following : 我建议使用以下内容

mvn -pl TheModuleYouHaveChanged -amd install

or maybe a 或一个

mvn -pl TheModuleYouHaveChanged -amd package

is enough. 足够。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM