Skip to content

add-module-info failure when JAR is already modular #179

@aalmiray

Description

@aalmiray

Invoking ModiTect's add-module-info goal as part of 2 separate build sessions causes an error

Error: /tmp/moditect-mcve/target/helloworld-1.0.0.jar is a modular JAR file that cannot be specified with the --generate-module-info option

jdeps fails because the JAR was made modular on the 1st build session.

Full MCVE available at https://github.com/aalmiray/moditect-mcve

$ gm build
Using maven at '/Users/aalmiray/.sdkman/candidates/maven/3.8.7/bin/mvn' to run buildFile '/tmp/moditect-mcve/pom.xml':
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< com.acme:helloworld >-------------------------
[INFO] Building helloworld 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/moditect-mcve/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ helloworld ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /tmp/moditect-mcve/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/moditect-mcve/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ helloworld ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ helloworld ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ helloworld ---
[INFO] Building jar: /tmp/moditect-mcve/target/helloworld-1.0.0.jar
[INFO] 
[INFO] --- moditect-maven-plugin:1.0.0.RC2:add-module-info (add-module-infos) @ helloworld ---
writing to /tmp/moditect-mcve/target/moditect/helloworld/versions/9/module-info.java
[INFO] Created module descriptor at /tmp/moditect-mcve/target/moditect/generated-sources/com.acme.helloworld/module-info.java
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.689 s
[INFO] Finished at: 2023-03-01T20:02:29+01:00
[INFO] ------------------------------------------------------------------------

$ gm build
Using maven at '/Users/aalmiray/.sdkman/candidates/maven/3.8.7/bin/mvn' to run buildFile '/tmp/moditect-mcve/pom.xml':
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< com.acme:helloworld >-------------------------
[INFO] Building helloworld 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/moditect-mcve/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ helloworld ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/moditect-mcve/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ helloworld ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ helloworld ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ helloworld ---
[INFO] 
[INFO] --- moditect-maven-plugin:1.0.0.RC2:add-module-info (add-module-infos) @ helloworld ---
Error: /tmp/moditect-mcve/target/helloworld-1.0.0.jar is a modular JAR file that cannot be specified with the --generate-module-info option
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.740 s
[INFO] Finished at: 2023-03-01T20:02:35+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.moditect:moditect-maven-plugin:1.0.0.RC2:add-module-info (add-module-infos) on project helloworld: Execution add-module-infos of goal org.moditect:moditect-maven-plugin:1.0.0.RC2:add-module-info failed: Invocation of jdeps failed: jdeps --generate-module-info /tmp/moditect-mcve/target/moditect --multi-release=9 /tmp/moditect-mcve/target/helloworld-1.0.0.jar -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

Metadata

Metadata

Assignees

No one assigned

    Labels

    releasedIssue has been released

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions