maven-compiler-plugin 在检查过时的源时是否考虑依赖关系?
Ant 的 depend 任务允许重新编译 Java 源代码,如果其任何依赖项 (引用的类,而不是模块依赖项)已被修改。我快速浏览了 org.apache.maven.plugin.CompilerMojo 和org.codehaus.plexus.compiler.util.scan.StaleSourceScanner 从表面上看,它们根本不考虑依赖关系。如果源代码的时间戳比类文件的时间戳新(加上一些增量),则看起来好像源代码被重新编译。
我是否错过了任何东西,或者 Maven 是否忽略了源代码未更改但其依赖项已更改的情况(因此它们都需要重新编译)?
Ant's depend task allows one to recompile Java source-code if any of its dependencies (referenced classes, not module dependencies) have been modified. I took a quick look at org.apache.maven.plugin.CompilerMojo and org.codehaus.plexus.compiler.util.scan.StaleSourceScanner and by the looks of it, they don't take dependencies into account at all. It looks as if source-code gets recompiled if its timestamp is newer than that of the class file (plus some delta).
Did I miss anything or is Maven disregarding the case where the source-code didn't change but its dependency did (hence they both need to be recompiled)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有错过任何东西。 Maven 忽略了这种情况。您必须通过干净的构建来解决它。
maven-versions-plugin 可以检查是否有新版本可用,所以有一半方程。干净的重建仍然是手动工作。
You did not miss anything. Maven is disregarding that case. You'll have to work around it with a clean build.
The maven-versions-plugin can check whether newer versions are available, so there's half the equation. The clean rebuild is still manual work.
我使用 maven-antrun-plugin。您可以在那里进行配置。但我不认为这是自动的。我的意思是你必须在第一次编译它时手动指定。之后,maven 会处理你的问题。
I use the maven-antrun-plugin. There you can configure it. I don't think it is automatic though. What I mean in you have to specify is manually first time you compile it. After wards maven handles your problem.