Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1897

Incorrect classpath due to JPMS magic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Reopened
    • Major
    • Resolution: Unresolved
    • None
    • 3.0.0-M6
    • None
    • None

    Description

      I converted my project to use CI friendly maven:

      https://maven.apache.org/maven-ci-friendly.html

      To fully simplify and get around bugs in M2E (maven eclipse plugin) I went away maintaining the version in .mvn/maven.config and simply set "revision" to "0-SNAPSHOT" in my parent POMs. When I build a release, I can override the "revision" to the actual release version.

      As a result now maven fails if I change the version of a sibling project I maintain and use to "0-SNAPSHOT" while the content of the code in the JARs has not changed at all.

      In the maven log I observed this warnings:

      [WARNING] Can't extract module name from mmm-l10n-en-0-SNAPSHOT.jar: mmm.l10n.en.0.SNAPSHOT: Invalid module name: '0' is not a Java identifier
      [WARNING] Can't extract module name from mmm-l10n-de-0-SNAPSHOT.jar: mmm.l10n.de.0.SNAPSHOT: Invalid module name: '0' is not a Java identifier
      [WARNING] Can't extract module name from mmm-l10n-es-0-SNAPSHOT.jar: mmm.l10n.es.0.SNAPSHOT: Invalid module name: '0' is not a Java identifier
      [WARNING] Can't extract module name from mmm-l10n-fr-0-SNAPSHOT.jar: mmm.l10n.fr.0.SNAPSHOT: Invalid module name: '0' is not a Java identifier
      [WARNING] Can't extract module name from mmm-l10n-all-0-SNAPSHOT.jar: mmm.l10n.all.0.SNAPSHOT: Invalid module name: '0' is not a Java identifier

      I launched the maven build with debugging (-X) both with the previous version 0.2.1-SNAPSHOT (working) and with 0-SNAPSHOT (failing). Here are the surefireargs for both variants:

      WORKING (0.2.1-SNAPSHOT dependency):

      --module-path
      /Users/hohwille/projects/mmm/workspaces/main/nls/core/target/classes
      :/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-scanner/0.2.1-SNAPSHOT/mmm-scanner-0.2.1-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-base/0.2.1-SNAPSHOT/mmm-base-0.2.1-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/org/slf4j/slf4j-api/2.0.0-alpha1/slf4j-api-2.0.0-alpha1.jar
      --class-path
      /Users/hohwille/.m2/repository/org/apache/maven/surefire/surefire-booter/2.22.2/surefire-booter-2.22.2.jar
      :/Users/hohwille/.m2/repository/org/apache/maven/surefire/surefire-api/2.22.2/surefire-api-2.22.2.jar
      :/Users/hohwille/.m2/repository/org/apache/maven/surefire/surefire-logger-api/2.22.2/surefire-logger-api-2.22.2.jar
      :/Users/hohwille/projects/mmm/workspaces/main/nls/core/target/test-classes:/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-l10n-all/0.2.1-SNAPSHOT/mmm-l10n-all-0.2.1-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-l10n-de/0.2.1-SNAPSHOT/mmm-l10n-de-0.2.1-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-l10n-en/0.2.1-SNAPSHOT/mmm-l10n-en-0.2.1-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-l10n-es/0.2.1-SNAPSHOT/mmm-l10n-es-0.2.1-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-l10n-fr/0.2.1-SNAPSHOT/mmm-l10n-fr-0.2.1-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar
      :/Users/hohwille/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar
      :/Users/hohwille/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar
      :/Users/hohwille/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
      :/Users/hohwille/.m2/repository/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar
      :/Users/hohwille/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar
      :/Users/hohwille/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar
      :/Users/hohwille/.m2/repository/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar
      :/Users/hohwille/.m2/repository/org/assertj/assertj-core/3.19.0/assertj-core-3.19.0.jar
      :/Users/hohwille/.m2/repository/ch/qos/logback/logback-classic/1.3.0-alpha5/logback-classic-1.3.0-alpha5.jar
      :/Users/hohwille/.m2/repository/ch/qos/logback/logback-core/1.3.0-alpha5/logback-core-1.3.0-alpha5.jar
      :/Users/hohwille/.m2/repository/com/sun/mail/javax.mail/1.6.2/javax.mail-1.6.2.jar
      :/Users/hohwille/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
      :/Users/hohwille/.m2/repository/edu/washington/cs/types/checker/checker-framework/1.7.0/checker-framework-1.7.0.jar
      :/Users/hohwille/.m2/repository/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.jar
      :/Users/hohwille/.m2/repository/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.jar
      --patch-module
      io.github.mmm.nls=/Users/hohwille/projects/mmm/workspaces/main/nls/core/target/test-classes
      --add-exports
      io.github.mmm.nls/io.github.mmm.nls=ALL-UNNAMED
      --add-modules
      io.github.mmm.nls
      --add-reads
      io.github.mmm.nls=ALL-UNNAMED
      org.apache.maven.surefire.booter.ForkedBooter 

      FAILING (0-SNAPSHOT):

      --module-path
      /Users/hohwille/projects/mmm/workspaces/main/nls/core/target/classes
      :/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-scanner/0-SNAPSHOT/mmm-scanner-0-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/io/github/m-m-m/mmm-base/0-SNAPSHOT/mmm-base-0-SNAPSHOT.jar
      :/Users/hohwille/.m2/repository/org/slf4j/slf4j-api/2.0.0-alpha1/slf4j-api-2.0.0-alpha1.jar
      --class-path
      /Users/hohwille/.m2/repository/org/apache/maven/surefire/surefire-booter/2.22.2/surefire-booter-2.22.2.jar
      :/Users/hohwille/.m2/repository/org/apache/maven/surefire/surefire-api/2.22.2/surefire-api-2.22.2.jar
      :/Users/hohwille/.m2/repository/org/apache/maven/surefire/surefire-logger-api/2.22.2/surefire-logger-api-2.22.2.jar
      :/Users/hohwille/projects/mmm/workspaces/main/nls/core/target/test-classes
      :/Users/hohwille/.m2/repository/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar
      :/Users/hohwille/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar
      :/Users/hohwille/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar
      :/Users/hohwille/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
      :/Users/hohwille/.m2/repository/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar
      :/Users/hohwille/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar
      :/Users/hohwille/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar
      :/Users/hohwille/.m2/repository/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar
      :/Users/hohwille/.m2/repository/org/assertj/assertj-core/3.19.0/assertj-core-3.19.0.jar
      :/Users/hohwille/.m2/repository/ch/qos/logback/logback-classic/1.3.0-alpha5/logback-classic-1.3.0-alpha5.jar
      :/Users/hohwille/.m2/repository/ch/qos/logback/logback-core/1.3.0-alpha5/logback-core-1.3.0-alpha5.jar
      :/Users/hohwille/.m2/repository/com/sun/mail/javax.mail/1.6.2/javax.mail-1.6.2.jar
      :/Users/hohwille/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
      :/Users/hohwille/.m2/repository/edu/washington/cs/types/checker/checker-framework/1.7.0/checker-framework-1.7.0.jar
      :/Users/hohwille/.m2/repository/org/apache/maven/surefire/surefire-junit-platform/2.22.2/surefire-junit-platform-2.22.2.jar
      :/Users/hohwille/.m2/repository/org/junit/platform/junit-platform-launcher/1.3.1/junit-platform-launcher-1.3.1.jar
      --patch-module
      io.github.mmm.nls=/Users/hohwille/projects/mmm/workspaces/main/nls/core/target/test-classes
      --add-exports
      io.github.mmm.nls/io.github.mmm.nls=ALL-UNNAMED
      --add-modules
      io.github.mmm.nls
      --add-reads
      io.github.mmm.nls=ALL-UNNAMED
      org.apache.maven.surefire.booter.ForkedBooter 

      So as you can see the surefire classpath is incorrect in the second case and simply omits the required test dependencies "mmm-l10n-*".

      As the warnings seem to be related to the bug but seem to originate from the maven compiler plugin I am not sure if this is surefire or a compiler plugin bug and filed it as general MNG issue.

      My project is OSS so you can find all here and reproduce:

      BROKEN:

      FIXED (temporary workaround):

      I am using maven-compiler-plugin 3.8.1:

      https://github.com/m-m-m/parent/blob/2ba9d23f35792f8fcf528b1e7b94c05ff5656fa1/pom.xml#L31

      and surefire 2.22.2:

      https://github.com/m-m-m/parent/blob/2ba9d23f35792f8fcf528b1e7b94c05ff5656fa1/pom.xml#L44

      Attachments

        Activity

          People

            tibordigana Tibor Digana
            hohwille Jörg Hohwiller
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: