The problem was difficult to uncover due to the swallowed exception at
https://github.com/apache/maven-surefire/blob/surefire-3.0.0-M7/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java#L1425-L1428
.

On Thu, Sep 1, 2022 at 4:05 PM Laird Nelson <[email protected]> wrote:

> The problem appears to be plexus-java 1.1.1's dependency on ASM 9.2.
> Adding a dependency on ASM 9.3 in my maven-surefire-plugin configuration
> fixed the problem.
>
>
>
> On Thu, Sep 1, 2022 at 12:54 PM Laird Nelson <[email protected]> wrote:
>
>> (That's the best subject line I could come up with.)
>>
>> I'm using maven-surefire-plugin 3.0.0-M7.
>>
>> I have a modular project (JPMS) with a module-info.java at src/main/java.
>> My module name is com.foo.mymodule.
>>
>> I have specified --source=18 and --target=18 to the compiler.  The
>> compiler is JDK 19 (early access).  I am not using toolchains.
>>
>> My test package (com.foo.mymodule.somepackage) is the same as my main
>> package.
>>
>> In my surefire configuration I have
>> --add-opens=com.foo.mymodule/com.foo.mymodule.somepackage=ALL-UNNAMED.
>>
>> When I run this it all works fine.
>>
>> HOWEVER: when I change --source and --target to 19, and make no other
>> changes, surefire no longer considers my project to be modular, and also
>> does not generate an args file.  For example, I can see my target/classes
>> directory showing up on the classpath instead of the module path, and I no
>> longer see [DEBUG] Path to args file: in my debug output.
>>
>> I've excerpted some debug output and put each Surefire-reported boot
>> classpath entry on its own line for clarity:
>>
>> With --source=18 everything looks good (note: no target/classes), and an
>> args file is produced:
>>
>> [DEBUG] boot classpath:
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-booter/3.0.0-M7/surefire-booter-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-api/3.0.0-M7/surefire-api-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-logger-api/3.0.0-M7/surefire-logger-api-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-shared-utils/3.0.0-M7/surefire-shared-utils-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-extensions-spi/3.0.0-M7/surefire-extensions-spi-3.0.0-M7.jar
>>
>> /Users/lairdnelson/Projects/github/ljnelson/forks/foo/foo-bar/target/test-classes
>>
>> /Users/lairdnelson/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.9.0/junit-jupiter-api-5.9.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/platform/junit-platform-commons/1.9.0/junit-platform-commons-1.9.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.9.0/junit-jupiter-engine-5.9.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/platform/junit-platform-engine/1.9.0/junit-platform-engine-1.9.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-junit-platform/3.0.0-M7/surefire-junit-platform-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/common-java5/3.0.0-M7/common-java5-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/platform/junit-platform-launcher/1.9.0/junit-platform-launcher-1.9.0.jar
>> [...]
>> [DEBUG] Path to args file:
>> /Users/lairdnelson/Projects/github/ljnelson/forks/foo/foo-bar/target/surefire/surefireargs-20220901122239246_3
>>
>> However, with --source=19 my project is no longer considered modular
>> (note target/classes and a modular jar dependency both showing up on the
>> classpath below) and no args file is produced:
>>
>> [DEBUG] boot classpath:
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-booter/3.0.0-M7/surefire-booter-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-api/3.0.0-M7/surefire-api-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-logger-api/3.0.0-M7/surefire-logger-api-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-shared-utils/3.0.0-M7/surefire-shared-utils-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-extensions-spi/3.0.0-M7/surefire-extensions-spi-3.0.0-M7.jar
>>
>> /Users/lairdnelson/Projects/github/ljnelson/forks/foo/foo-bar/target/test-classes
>> /Users/lairdnelson/Projects/github/ljnelson/forks/foo/foo-bar/target/classes
>> ### NOTE
>> /Users/lairdnelson/.m2/repository/com/foo/some/other/dependency/that/is/modular/0.0.1/some-modular-jar-dependency-0.0.1.jar
>> ### NOTE
>>
>> /Users/lairdnelson/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.9.0/junit-jupiter-api-5.9.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/platform/junit-platform-commons/1.9.0/junit-platform-commons-1.9.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.9.0/junit-jupiter-engine-5.9.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/platform/junit-platform-engine/1.9.0/junit-platform-engine-1.9.0.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/surefire-junit-platform/3.0.0-M7/surefire-junit-platform-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/apache/maven/surefire/common-java5/3.0.0-M7/common-java5-3.0.0-M7.jar
>>
>> /Users/lairdnelson/.m2/repository/org/junit/platform/junit-platform-launcher/1.9.0/junit-platform-launcher-1.9.0.jar
>>
>> The fact that no args file is produced makes me think that this override (
>> https://github.com/apache/maven-surefire/blob/surefire-3.0.0-M7/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java#L80)
>> is not being called when the compiler's --source flag is 19.  I have no
>> idea how that would happen.
>>
>> For now my workaround is to continue with --source=18 (I'm not really
>> using 19 features yet).  I'm quite curious to know how this would cause
>> different branching inside Surefire, however.
>>
>> Shall I file an issue?
>>
>> Best,
>> Laird
>>
>>

Reply via email to