maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simone Bordet (JIRA)" <>
Subject [jira] [Commented] (SUREFIRE-1667) Crash with JPMS "requires static"
Date Sun, 19 May 2019 23:05:00 GMT


Simone Bordet commented on SUREFIRE-1667:

[~rfscholte] maybe I'm wrong, but should not {{require static}} also be respected at compile-time?

As {{requires static}} has the same semantic of Maven's {{optional=true}}, if {{moduleA}}
has a non-test dependency on {{moduleC}} then it must explicitly declare it - just depending
on {{moduleB}} (which has an optional dependency on {{moduleC}}) will yield a compilation
failure, no?

> Crash with JPMS "requires static"
> ---------------------------------
>                 Key: SUREFIRE-1667
>                 URL:
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 3.0.0-M3
>            Reporter: Simone Bordet
>            Priority: Major
>         Attachments: surefire-jpms-issue.tgz
> The attached project has JPMS modules where:
> {{moduleA}} requires {{moduleB}}
> {{moduleB}} requires static {{moduleC}}.
> Furthermore, {{moduleA}} tests require {{moduleC}}.
> Running the attached project ends up with the following test failure:
> {code}
> [ERROR] test(org.cometd.a.ATest) Time elapsed: 0.01 s <<< ERROR!
> java.lang.NoClassDefFoundError: org/cometd/c/C
>  at moduleA@1.0.0-SNAPSHOT/org.cometd.a.ATest.test(
> {code}
> The reason is that {{plexus-java}} creates a wrong module-path and class-path because
it does not take into account the {{static}} modified in the JPMS directive {{requires static
> For the attached project, running {{moduleA}} tests generates this (simplified):
> {code}
> --module-path
> moduleA/target/classes:
> moduleB-1.0.0-SNAPSHOT.jar:
> moduleC-1.0.0-SNAPSHOT.jar
> --class-path
> surefire-booter-3.0.0-M3.jar:
> surefire-api-3.0.0-M3.jar:
> surefire-logger-api-3.0.0-M3.jar:
> junit-4.12.jar:
> hamcrest-core-1.3.jar:
> surefire-junit4-3.0.0-M3.jar:
> common-java5-3.0.0-M3.jar:
> common-junit3-3.0.0-M3.jar:
> common-junit4-3.0.0-M3.jar"
> --patch-module
> moduleA=moduleA/target/test-classes
> --add-exports
> moduleA/org.cometd.a=ALL-UNNAMED
> --add-modules
> moduleA
> --add-reads
> {code}
> However, {{moduleC}} should be in the class-path, not in the module-path, as it is only
required for testing.
> It is in the module-path because it is pulled in as a transitive dependency from {{moduleB}},
without taking into account that it is a {{requires static}}.
> Correct behavior should be IMHO that {{moduleC}} is not in the module-path but rather
in the class-path, respecting the semantic of JPMS {{requires static}}.
> The workaround is to configure the Maven Surefire Plugin with {{--add-module moduleC}},
but that is incorrect.
> The relevant {{plexus-languages/plexus-java}} code that builds the module-path and the
class-path is in {{LocationManager.resolvePaths()}}. 

This message was sent by Atlassian JIRA

View raw message