英文:
Building parent project always recompiles all modules
问题
我有一个父项目,里面有很多子模块(这是一个Netbeans平台应用程序)。该应用程序可以成功构建和运行。
如果我在父项目上运行 mvn compile
两次,第二次很快,因为Maven会对所有模块说“无需编译 - 所有类都是最新的”。很好。
如果我在父项目上运行 mvn install
两次,第二次与第一次一样长,因为只有第一个模块被视为“最新”。Maven检测到所有其他模块的更改并重新编译源代码。
我使用 mvn -X
尝试理解发生了什么。对于第二个模块 org-jjazz-upgrade
,我得到了这个:
[DEBUG] 检测到新的依赖项:D:\JeromeDocs\NetBeansProjects\JJazzLab\modules\Utilities\target\org-jjazz-utilities-1.0-SNAPSHOT.jar
[INFO] 检测到更改 - 重新编译该模块!
org-jjazz-utilities
是第一个被视为最新的模块...
有办法避免在 install
目标中进行这种全局重新编译吗?
带有 mvn -X install
日志的项目源代码(请参见 install.txt
)可在 此处 找到。
英文:
I have a parent project with many child modules (it's a Netbeans platform application). The app builds and runs OK.
If I run mvn compile
on the parent project twice, the 2nd time it's fast because Maven says "Nothing to compile - all classes are up to date" for all the modules. Good.
If I run mvn install
on the parent project twice, the 2nd time is as long as the 1st one because only the first module is seen as "up to date". Maven detects changes for all the other modules and recompiles the source code.
I used mvn -X
to try to understand what happens. For the 2nd module org-jjazz-upgrade
I get this:
[DEBUG] New dependency detected: D:\JeromeDocs\NetBeansProjects\JJazzLab\modules\Utilities\target\org-jjazz-utilities-1.0-SNAPSHOT.jar
[INFO] Changes detected - recompiling the module!
org-jjazz-utilities
is the first module which was up to date...
Is there a way to avoid this global recompilation with the install
goal ?
Project source code with mvn -X install
log (see install.txt
) is available here.
答案1
得分: 2
这是翻译好的部分:
"Well, it's due to a maven-compiler-plugin bug documented here, and has been unsolved for almost 10 years, despite many votes..."
我只是不得不在插件配置中将 useIncrementalCompilation
设置为 false
(我使用的是 3.10.0 版本),然后它就正常工作了。相当反直觉的...
英文:
Well, it's due to a maven-compiler-plugin bug documented here, and has been unsolved for almost 10 years, despite many votes...
I just had to set useIncrementalCompilation
to false
in the plugin configuration (I use 3.10.0) and then it worked "normally". Quite counter-intuitive...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论