[ https://issues.apache.org/jira/browse/SUREFIRE-1501?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stephen Colebourne updated SUREFIRE-1501: ----------------------------------------- Description: Attached is a pointlessly simple project for Java 9. The module-info declares an _optional_ dependency on Google Guava (an automatic module) using _requires static_. This optionality is reflected in the pom.xml, where the dependency is marked as optional. It fails in surefire with JAVA_HOME=jdk9. The reason seems to be that although the Guava jar file is added to the modulepath, it is not referenced using --add-modules. As such, the module graph builder never pulls it in, despite it being on the modulepath. (Optional dependencies need to be directly added using --add-modules if in Maven's dependency graph) Adding the --add-modules to the `argLine` parameter solves the problem, but this is a bug because the surefire plugin should handle the situation without manually adding it. NOTE! The attachment has the --add-modules manually added to the pom.xml. Remove it to see the bug. was: Attached is a pointlessly simple project for Java 9. The module-info declares an _optional_ dependency on Google Guava (an automatic module) using _requires static_. This optionality is reflected in the pom.xml, where the dependency is marked as optional. It fails in surefire with JAVA_HOME=jdk9. The reason seems to be that although the Guava jar file is added to the modulepath, it is not referenced using --add-modules. As such, the module graph builder never pulls it in, despite it being on the modulepath. (Optional dependencies need to be directly added using --add-modules if in Maven's dependency graph) Adding the --add-modules to the `argLine` parameter solves the problem, but this is a bug because the surefire plugin should handle the situation without manually adding it. > Optional dependencies not correctly handled with JPMS modules > ------------------------------------------------------------- > > Key: SUREFIRE-1501 > URL: https://issues.apache.org/jira/browse/SUREFIRE-1501 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin > Affects Versions: 2.21.0 > Environment: Windows 10, Maven v3.5.2 > Reporter: Stephen Colebourne > Priority: Major > Attachments: maven-issue1.zip > > > Attached is a pointlessly simple project for Java 9. The module-info declares > an _optional_ dependency on Google Guava (an automatic module) using > _requires static_. This optionality is reflected in the pom.xml, where the > dependency is marked as optional. > It fails in surefire with JAVA_HOME=jdk9. The reason seems to be that > although the Guava jar file is added to the modulepath, it is not referenced > using --add-modules. As such, the module graph builder never pulls it in, > despite it being on the modulepath. (Optional dependencies need to be > directly added using --add-modules if in Maven's dependency graph) > Adding the --add-modules to the `argLine` parameter solves the problem, but > this is a bug because the surefire plugin should handle the situation without > manually adding it. > NOTE! The attachment has the --add-modules manually added to the pom.xml. > Remove it to see the bug. -- This message was sent by Atlassian JIRA (v7.6.3#76005)