Maven的编译器插件总是检测一组源AS"陈旧" [英] Maven compiler plugin always detecting a set of sources as "stale"

查看:246
本文介绍了Maven的编译器插件总是检测一组源AS"陈旧"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

固定:这是Maven的编译器插件中的已知的bug 3.1

我转换了1000多个Java的源项目的一个基于Ant的构建,以行家。到目前为止好,但每次推出的 MVN编译将其重新编译一切(而不是重用老班)

使用 MVN -X编译报道说,

  [DEBUG]陈旧源检测:/project_path/src/main/java/package_path/AFile1.java
[DEBUG]陈旧源检测:/project_path/src/main/java/package_path/AFile2.java
...

只适用于某个软件包,这是从code的其余部分可能未引用的文件,不是我的消息来源,我只是想mavenize编译)

编译没有失败,并且正在以

产生与更新时间戳班

  /project_path/target/classes/package_path/AFile1.class
/project_path/target/classes/package_path/AFile2.class
...

不过,看着时间戳时,java文件还没有从昨天起改变,类文件都是最新的。为什么这些来源确定为过时?如何调试这个问题?

这是一拖必须还要重新编译1K +文件时,情况发生变化,...


示例输出:

  $ MVN清洁编译
[INFO]扫描项目...
[信息]
[INFO] ----------------------------------------------- -------------------------
[INFO]大厦MYPROJECT 1.9.0-SNAPSHOT
[INFO] ----------------------------------------------- -------------------------
【警告】为net.sourceforge的POM:jffmpeg:罐子:1.1.0丢失,可用的依赖信息
[信息]
[信息] --- Maven的清理插件:2.4.1:清洁(默认清洁)@我的项目---
[INFO]删除/ project_path /目标
[信息]
[信息] --- Maven的资源 - 插件:2.5:资源(缺省资源)@我的项目---
[调试]执行情境化
[信息]使用UTF-8编码复制过滤资源。
[信息]跳到不存在的resourceDirectory / project_path / src目录/主/资源
[信息]
[信息] --- Maven的编译器插件:3.1:编译(默认编译)@我的项目---
检测[INFO]的变化 - 重新编译模块!
[INFO] 1162编译源文件project_path /目标/班
....
[INFO] ----------------------------------------------- -------------------------
[INFO] BUILD成功
[INFO] ----------------------------------------------- -------------------------
[INFO]总时间:11.215s
[INFO]在表面处理:周二7月30日十​​二时42分25秒CEST 2013
[INFO]最后的内存:25M / 429M
[INFO] ----------------------------------------------- -------------------------$ MVN编译
[INFO]扫描项目...
[信息]
[INFO] ----------------------------------------------- -------------------------
[INFO]大厦MYPROJECT 1.9.0-SNAPSHOT
[INFO] ----------------------------------------------- -------------------------
【警告】为net.sourceforge的POM:jffmpeg:罐子:1.1.0丢失,可用的依赖信息
[信息]
[信息] --- Maven的资源 - 插件:2.5:资源(缺省资源)@我的项目---
[调试]执行情境化
[信息]使用UTF-8编码复制过滤资源。
[信息]跳到不存在的resourceDirectory / project_path / src目录/主/资源
[信息]
[信息] --- Maven的编译器插件:3.1:编译(默认编译)@我的项目---
检测[INFO]的变化 - 重新编译模块!
[INFO] 1162编译源文件/ project_path /目标/班
...
[INFO] ----------------------------------------------- -------------------------
[INFO] BUILD成功
[INFO] ----------------------------------------------- -------------------------
[INFO]总时间:12.140s
[INFO]在表面处理:周二7月30日十​​二时42分44秒CEST 2013
[INFO]最后的内存:22M / 379M
[INFO] ----------------------------------------------- -------------------------


解决方案

这是在Maven的编译器插件3.1的已知问题。它是在<一个被跟踪href=\"https://issues.apache.org/jira/browse/MCOMPILER-209\">https://issues.apache.org/jira/browse/MCOMPILER-209 (在 useIncrementalCompilation 标志被打破)。

问题是无关的另一个错误3.1,<一个href=\"https://issues.apache.org/jira/browse/MCOMPILER-205\">https://issues.apache.org/jira/browse/MCOMPILER-205 (其中,不产生的.class输出文件始终标记为过时)。

进一步的测试,要回3.0实际上并没有解决这个问题(它只能直到下一个 MVN清洁编译后。但是,迈克尔·莱姆克建议在评论中,标记 useIncrementalCompilation 是一个可行的替代品;现在,只有有问题的包被每一次(而不是整个重新编译code-基地)。

FIXED: this is a known bug in maven-compiler-plugin 3.1

I am converting an ant-based build of a 1000+ java-sources project to maven. So far so good, but every time launch mvn compile it recompiles everything (instead of reusing old classes)

Using mvn -X compile reports that

[DEBUG] Stale source detected: /project_path/src/main/java/package_path/AFile1.java
[DEBUG] Stale source detected: /project_path/src/main/java/package_path/AFile2.java
...

(only for files in a certain package, which is possibly unreferenced from the rest of the code; not my sources, I am just trying to mavenize the build)

Compilation does not fail, and classes with updated timestamps are being generated at

/project_path/target/classes/package_path/AFile1.class
/project_path/target/classes/package_path/AFile2.class
...

However, when looking at timestamps, the java files have not changed since yesterday, and the class files are current. Why are these sources determined to be stale? How can I debug this issue?.

It is a drag to have to recompile 1k+ files even when no changes have occurred...


Sample output:

$ mvn clean compile
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject 1.9.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for net.sourceforge:jffmpeg:jar:1.1.0 is missing, no dependency information available
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ my-project ---
[INFO] Deleting /project_path/target
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ my-project ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /project_path/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1162 source files to project_path/target/classes
....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.215s
[INFO] Finished at: Tue Jul 30 12:42:25 CEST 2013
[INFO] Final Memory: 25M/429M
[INFO] ------------------------------------------------------------------------



$ mvn compile
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject 1.9.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for net.sourceforge:jffmpeg:jar:1.1.0 is missing, no dependency information available
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ my-project ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /project_path/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my-project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1162 source files to /project_path/target/classes
... 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.140s
[INFO] Finished at: Tue Jul 30 12:42:44 CEST 2013
[INFO] Final Memory: 22M/379M
[INFO] ------------------------------------------------------------------------

解决方案

This is a known problem in maven-compiler-plugin 3.1. It is being tracked in https://issues.apache.org/jira/browse/MCOMPILER-209 (the useIncrementalCompilation flag is broken).

The problem is unrelated to another 3.1 bug, https://issues.apache.org/jira/browse/MCOMPILER-205 (where files that do not produce .class outputs are always flagged as 'stale').

After testing further, going back to 3.0 did not actually fix the problem (it only works until the next mvn clean compile. However, as Michael Lemke suggests in comments, marking useIncrementalCompilation to false is a workable substitute; now, only the offending package gets recompiled each time (instead of the whole code-base).

这篇关于Maven的编译器插件总是检测一组源AS&QUOT;陈旧&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆