具有不同项目目录路径的奇怪 Maven 行为

发布于 2024-10-09 17:14:18 字数 1781 浏览 0 评论 0原文

我的 Java 项目有一个新的 git 克隆,位于 C:\dev\1234567890(不用担心名称),并且命令 mvn cleancompileBUILD SUCCESS 结尾>。然而 Maven 没有编译我的项目中的所有类,并且再次命令 mvncompile (不带 clean)编译其余的类。这意味着 mvn clean test 将因缺少已编译的类而失败。

C:\dev\1234567890> mvn 干净编译
...
[INFO] 编译 708 源文件到 C:\dev\1234567890\target\classes
...
[信息] ---------------------------------------------------------- ------------
[信息] 取得成功  
[信息] ---------------------------------------------------------- ------------

C:\dev\1234567890>mvn 编译
...
[INFO] 编译 690 个源文件到 C:\dev\1234567890\target\classes
...
[信息] ---------------------------------------------------------- ------------
[信息] 取得成功  
[信息] ---------------------------------------------------------- ------------

第三次运行会告诉我所有课程都是最新的。

事情变得奇怪的地方。以下操作将以成功构建结束(使用mvn clean test)。

C:\dev\1234567890>cd ..
C:\dev>mv 1234567890 12345678901
C:\dev>cd 12345678901
C:\dev\12345678901>mvn clean 测试
...
[信息] ---------------------------------------------------------- ---------
[信息] 取得成功
[信息] ---------------------------------------------------------- ---------
[信息] 总时间:19.955s
[INFO] 结束时间: 2010 年 12 月 29 日星期三 11:57:52 EET
[信息]最终内存:4M/58M
[信息] ---------------------------------------------------------- ---------

然后,如果我将目录名称更改为原始名称(或更改为 10 个字符长),我最终将导致构建失败。似乎只有目录名称的长度有影响(所有 <11 的内容都会导致构建失败)。我错过了什么吗?有什么想法吗?我已经脱离了他们。

<前><代码>mvn -版本 Apache Maven 3.0.1(r1038046;2010-11-23 12:58:32+0200) Java版本:1.5.0_22 Java 主目录:C:\Program Files (x86)\Java\jdk1.5.0_22\jre 默认区域设置:fi_FI,平台编码:Cp1252 操作系统名称:“windows 7”版本:“6.1”架构:“x86”系列:“windows”

I have a fresh git clone of my Java project located at C:\dev\1234567890 (don't worry about the name yet) and commanding mvn clean compile ends with BUILD SUCCESS. How ever Maven does not compile all the classes in my project and commanding again mvn compile (without clean) compiles rest of the classes. This means that mvn clean test will fail because of missing compiled classes.

C:\dev\1234567890> mvn clean compile
...
[INFO] Compiling 708 source files to C:\dev\1234567890\target\classes
...
[INFO] ----------------------------------------------------------
[INFO] BUILD SUCCESS  
[INFO] ----------------------------------------------------------

C:\dev\1234567890>mvn compile
...
[INFO] Compiling 690 source files to C:\dev\1234567890\target\classes
...
[INFO] ----------------------------------------------------------
[INFO] BUILD SUCCESS  
[INFO] ----------------------------------------------------------

Third run will tell me that all classes are up to date.

Where things go weird. Following operations will end in a successful build (with mvn clean test).

C:\dev\1234567890>cd ..
C:\dev>mv 1234567890 12345678901
C:\dev>cd 12345678901
C:\dev\12345678901>mvn clean test
...
[INFO] --------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------------
[INFO] Total time: 19.955s
[INFO] Finished at: Wed Dec 29 11:57:52 EET 2010
[INFO] Final Memory: 4M/58M
[INFO] --------------------------------------------------------

Then again if I change the name of the directory to the original (or to what ever 10 characters long) I will end up with BUILD FAILURE. It seems that only the length of the directory name makes a difference (everything <11 will result a build failure). Am I missing something? Any ideas? I am out of them.

mvn -version
Apache Maven 3.0.1 (r1038046; 2010-11-23 12:58:32+0200)
Java version: 1.5.0_22
Java home: C:\Program Files (x86)\Java\jdk1.5.0_22\jre
Default locale: fi_FI, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "x86" Family: "windows"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦里寻她 2024-10-16 17:14:18
C:\dev\1234567890> mvn 干净编译
[INFO] 编译 708 源文件到 C:\dev\1234567890\target\classes

C:\dev\1234567890>mvn 编译
[INFO] 编译 690 个源文件到 C:\dev\1234567890\target\classes

一种可能的解释是,您有一些 Maven 插件可以生成附加到编译阶段的 Java 源代码。在第一次调用中,它将在编译器之后执行并生成源代码,在第二次调用中,源代码已经存在,因此编译器也会使用它们。

如果您确实有一个生成 java 源代码的插件,请始终将其映射到 generate-sourcesgenerate-test-sources 阶段。

C:\dev\1234567890> mvn clean compile
[INFO] Compiling 708 source files to C:\dev\1234567890\target\classes

C:\dev\1234567890>mvn compile
[INFO] Compiling 690 source files to C:\dev\1234567890\target\classes

One possible explanation would be that you have some maven plugin that generates Java Source code attached to the compile phase. In the first call, it would execute after the compiler and generate the sources, in the second call the sources would already be present, so the compiler would use them as well.

If you do have a plugin that generates java source, always map it to the phases generate-sources and generate-test-sources.

一页 2024-10-16 17:14:18

我成功解决了从 JDK 1.5 切换到 1.6 的问题。但我仍然不知道为什么它不能在 JDK 1.5 上正常工作。

I managed to solve my problems switching from JDK 1.5 to 1.6. But I still have no clue why it didn't work properly with JDK 1.5.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文