3

YES I did mvn clean.

Tried in Maven 3.1.0, 3.0.4 and 3.0.3

My multi-module maven project's build (mvn install) fails at some module. The cause is that the last module was built with SUCCESS, but in fact the jar is empty. And then the next module can't find the classes that it needs to see.

[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

Here is the complete debug output from running mvn -X clean install -amd -Dmaven.test.skip=true > build.log http://nopaste.info/7f07571993.html

In IntelliJ IDEA it all looks good, the class exists.

Not just the generated jar is empty, also the folder service/api/target/classes.

My pom file for service-api is very basic, just like the others that work:

<?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>

No maven plugins here.

I don't think I have a cyclic dependency, because Maven 3 would detect this.

UPDATE

I've now got it down to this: a simple mvn compile on the module that creates the empty jar gives me this output in 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] ------------------------------------------------------------------------

And right after running that, the folder C:\myproject\trunk-checkout2\service\api\target\classes is empty. So the 217 Java classes are detected, maven says it compiles them and puts them into my target folder, but it does not.

Update 2

I've compared the output of mvn -X compile of a module that works compared to this one (remember, all end in BUILD SUCCESS but this one has an empty target folder). There is a difference: the failing one lists all java files as "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] ------------------------------------------------------------------------

I've seen this bug report https://jira.codehaus.org/browse/MCOMPILER-205 and I do have package-info.java files in this module, but I've tried a pre-3 compiler plugin, same result. And I've tried with an annotation as described there, no luck either. So I don't think it's the same case.

I don't have a public static void main, thus this bug Workaround for javac compilation order bug in maven can't be it.

UPDATE 3

There's an abort in javac, without notice (-verbose turned on). Just 1 class works, all 217 fails. So I guess I have to try to find which causes it, etc... will post again.

4

2 回答 2

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 

这给我的印象是您正在使用测试类,或者可能是来自测试区域的包名称,这将不起作用,或者您缺少对其他包的依赖。

于 2013-07-24T17:27:15.760 回答
0

原因是由于 javac 中的错误。它无法处理的一些有效语法。然后生成空罐子,依此类推。

于 2015-10-24T16:30:58.277 回答