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.

Community
  • 1
  • 1
Gonfi den Tschal
  • 1,754
  • 1
  • 20
  • 29

2 Answers2

0

First in your log output there are several hints about things like ${version} which you should fix furthermore there are other warnings about duplicate definitions of dependencies etc.

I have taken a deeper look into the log output:

[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 

which gives me the impression that you are using test classes or may be package names from the test area which will not work or you are missing a dependency to an other package.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • those folder names like C:devmythingmyprojecttrunk-checkout2servicespis were mangled by nopaste (even though i selected 'plain'). they are not the problem. the reported problem with the missing packages/classes is exactly because they should be in the empty jar. – Gonfi den Tschal Jul 24 '13 at 19:05
-1

The cause was due to a bug in javac. Some valid syntax it could not handle. That then generated the empty jar, and so on.

Gonfi den Tschal
  • 1,754
  • 1
  • 20
  • 29