是的我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.log
http://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文件列为“检测到过时的源”。
[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个都失败了。所以我想我必须尝试找到导致它的原因等等......将再次发布。
答案 0 :(得分:0)
首先在日志输出中有一些关于${version}
之类的提示,您应该修复这些提示,还有其他有关依赖项重复定义的警告等。
我已经深入研究了日志输出:
[ERROR] C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespivalidationfakeAbstractConfigurableFakeDetector.java:[12,55] error: package org.myself.service.validation.fake does not exist
[ERROR] C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespivalidationfakeAbstractConfigurableFakeDetector.java:[13,55] error: package org.myself.service.validation.fake does not exist
[ERROR] C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespivalidationfakeAbstractConfigurableFakeDetector.java:[82,14] error: cannot find symbol
[ERROR] symbol: class SimpleValidationResult
location: class AbstractConfigurableFakeDetector
C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespivalidationfakeAbstractConfigurableFakeDetector.java:[106,66] error: cannot find symbol
[ERROR] symbol: class FakeType
location: class AbstractConfigurableFakeDetector
C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespivalidationfakeAbstractConfigurableFakeDetector.java:[97,8] error: cannot find symbol
[ERROR] symbol: class SimpleValidationResult
location: interface SomethingThatReturnsValidationResult
C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespigenderresultAverageComputedGenderResultCollector.java:[4,46] error: package org.myself.service.gender does not exist
[ERROR] C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespigenderresultAverageComputedGenderResultCollector.java:[5,46] error: package org.myself.service.gender does not exist
[ERROR] C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespigenderresultAbstractAverageGenderCollector.java:[4,46] error: package org.myself.service.gender does not exist
[ERROR] C:devmythingmyprojecttrunk-checkout2servicespisrcmainjavaorgmyselfservicespigenderresultAverageComputedGenderResultCollector.java:[31,29] error: cannot find symbol
[ERROR] symbol: class ComputedGenderResult
location: class AverageComputedGenderResultCollector
这给我的印象是你正在使用测试类,或者可能是测试区域中的包名称不起作用,或者你缺少对其他包的依赖。
答案 1 :(得分:0)
原因是由于javac中的错误。它无法处理的一些有效语法。然后生成了空罐子,等等。