【发布时间】:2013-07-24 15:38:37
【问题描述】:
是的,我做到了mvn clean。
在 Maven 3.1.0、3.0.4 和 3.0.3 中尝试过
我的多模块 maven 项目的构建 (mvn install) 在某些模块处失败。原因是最后一个模块是用SUCCESS构建的,但实际上jar是空的。然后下一个模块找不到它需要查看的类。
[INFO] Reactor Summary:
[INFO]
[INFO] myproject ......................................... SUCCESS [0.309s]
[INFO] myproject-service ................................. SUCCESS [0.011s]
[INFO] myproject-service-api ............................ SUCCESS [1.242s]
[INFO] myproject-service-spi ............................ FAILURE [1.422s]
[INFO] myproject-datap-lib-impl .................. SKIPPED
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.746s
[INFO] Finished at: Wed Jul 24 17:30:57 EEST 2013
[INFO] Final Memory: 62M/919M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project myproject-service-spi: Compilation failure: Compilation failure:
[ERROR] C:\dev\mything\myproject\trunk-checkout2\service\spi\src\main\java\org\myself\service\spi\validation\fake\AbstractConfigurableFakeDetector.java:[12,55] error: package org.myself.service.validation.fake does not exist
这是运行mvn -X clean install -amd -Dmaven.test.skip=true > build.loghttp://nopaste.info/7f07571993.html的完整调试输出
在 IntelliJ IDEA 中一切看起来都不错,类存在。
不仅生成的jar是空的,文件夹service/api/target/classes也是。
我的 service-api 的 pom 文件非常基本,就像其他工作一样:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>myparent</artifactId>
<groupId>my.parent</groupId>
<version>myversion</version>
</parent>
<groupId>myproject.service.api</groupId>
<artifactId>myproject-service-api</artifactId>
<dependencies>
... some local and external dependencies
</dependencies>
<properties>
</properties>
</project>
这里没有 maven 插件。
我认为我没有循环依赖,因为 Maven 3 会检测到这一点。
更新
我现在明白了这一点:在创建空 jar 的模块上进行简单的 mvn 编译,在 IntelliJ IDEA 中为我提供了以下输出:
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject-service-api 4.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myproject-service-api ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\myproject\trunk-checkout2\service\api\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myproject-service-api ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 217 source files to C:\myproject\trunk-checkout2\service\api\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.908s
[INFO] Finished at: Wed Jul 24 21:56:49 EEST 2013
[INFO] Final Memory: 20M/232M
[INFO] ------------------------------------------------------------------------
在运行之后,文件夹 C:\myproject\trunk-checkout2\service\api\target\classes 是空的。所以检测到 217 个 Java 类,maven 说它会编译它们并将它们放入我的目标文件夹,但它没有。
更新 2
我已经比较了一个模块的mvn -X compile 的输出与这个模块相比(请记住,所有模块都以 BUILD SUCCESS 结尾,但这个模块有一个空的目标文件夹)。有一个区别:失败的文件将所有 java 文件列为“Stale source detected”。
[DEBUG] Using compiler 'javac'.
[DEBUG] Source directories: [C:\myproject\trunk-checkout2\service\api\src\main\java]
[DEBUG] Classpath: [C:\myproject\trunk-checkout2\service\api\target\classes
... all the dependency jars
[DEBUG] Output directory: C:\myproject\trunk-checkout2\service\api\target\classes
[DEBUG] CompilerReuseStrategy: reuseCreated
[DEBUG] useIncrementalCompilation enabled
[DEBUG] Stale source detected: C:\dev\myproject\trunk-checkout2\service\api\src\main\java\my\Class.java
... listing all 217 classes
[INFO] Changes detected - recompiling the module!
[DEBUG] Classpath:
[DEBUG] C:\myproject\trunk-checkout2\service\api\target\classes
... all the dependency jars
[DEBUG] Source roots:
[DEBUG] C:\myproject\trunk-checkout2\service\api\src\main\java
[DEBUG] Command line options:
[DEBUG] -d (...) -g -nowarn -target 1.6 -source 1.6 -encoding UTF-8
[DEBUG] incrementalBuildHelper#beforeRebuildExecution
[INFO] Compiling 217 source files to C:\myproject\trunk-checkout2\service\api\target\classes
[DEBUG] incrementalBuildHelper#afterRebuildExecution
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.060s
[INFO] Finished at: Wed Jul 24 23:16:37 EEST 2013
[INFO] Final Memory: 22M/328M
[INFO] ------------------------------------------------------------------------
我已经看到这个错误报告https://jira.codehaus.org/browse/MCOMPILER-205 并且我确实在这个模块中有 package-info.java 文件,但是我尝试了一个 pre-3 编译器插件,结果相同。而且我已经尝试过那里描述的注释,也没有运气。所以我认为情况并非如此。
我没有 public static void main,因此这个 bug Workaround for javac compilation order bug in maven 不可能。
更新 3
javac 中止,没有通知(-verbose 开启)。仅 1 节课有效,所有 217 节课均失败。所以我想我必须尝试找出导致它的原因,等等......会再次发布。
【问题讨论】: