[ 
https://issues.apache.org/jira/browse/SUREFIRE-1733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17142664#comment-17142664
 ] 

Christian Stein commented on SUREFIRE-1733:
-------------------------------------------

Java modules are declared by developers -- no build tool can 100% correctly 
guess what should be included (exported, opened, ...) in a Java module.

Having said that, and guessing from your issue description, you want to perform 
"in-module" tests. That means you module-under-test and your test module are 
virtually merged such as if they see the same sources (read packages) and 
resources (read packages, again). In this case, the resources of the 
"test/resources" and the "main/resources" should be virtually merged, too.

So, I consider the missing "--patch-module 
my.project=.../myproject/src/main/resources" a missing feature.

Note: this does NOT apply to "extra-module" testing, i.e. when you test module 
uses a different name compared to the one of the main module. Here the 
developer of the main module is in charge of providing all classes and 
resources.

> Surefire and Failsafe JPMS additions for JUnit 5.x execution
> ------------------------------------------------------------
>
>                 Key: SUREFIRE-1733
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1733
>             Project: Maven Surefire
>          Issue Type: Improvement
>          Components: Maven Failsafe Plugin, Maven Surefire Plugin
>    Affects Versions: 2.22.2, 3.0.0-M4
>            Reporter: John Patrick
>            Assignee: Tibor Digana
>            Priority: Minor
>             Fix For: 3.0.0-M5
>
>         Attachments: surefire-v2.22.2_junit-v5.5.2.txt, 
> surefire-v2.22.2_junit-v5.6.0-M1.txt, surefire-v3.0.0-M4_junit-v5.5.2.txt, 
> surefire-v3.0.0-M4_junit-v5.6.0-M1.txt
>
>
> Following on from SUREFIRE-1731 it was highlighted that some projects need 
> extra '--add-open' options for JUnit to execute correctly, lots have already 
> been handled or added or supported in previous releases but I'm needing to 
> add these for a project to run correctly.
> I'm happy to start looking at a patch, but need help with where repo or class 
> to start looking at.
> This is what extra arguments I'm needing to pass to surefire/failsafe.
> {code}
> --add-opens 
> ${project.Automatic-Module-Name}/${project.Automatic-Module-Name}=ALL-UNNAMED
> --add-opens 
> ${project.Automatic-Module-Name}/${project.Automatic-Module-Name}=org.junit.platform.commons
> --add-opens 
> org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED
> --add-opens 
> org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED
> {code}
> Luckly my module names and package names are all on the same standard and 
> I've got a maven property for each sub module defining what 
> 'project.Automatic-Module-Name' is.
> The 2nd two are probably easy and will work for everyone, the 1st two might 
> require some discussion and maybe define two variables that surefire and 
> failsafe can use, one for the module name and one for the package name if 
> they can dynamically scan the source code and work it out.
> This is the stacktrace I'm seeing;
> {code}
> [ERROR] Failed to execute goal 
> org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on 
> project PROJECT: There are test failures.
> [ERROR] 
> [ERROR] Please refer to PATH/target/surefire-reports for the individual test 
> results.
> [ERROR] Please refer to dump files (if any exist) [date].dump, 
> [date]-jvmRun[N].dump and [date].dumpstream.
> [ERROR] There was an error in the forked process
> [ERROR] java.lang.IllegalAccessError: class 
> org.junit.platform.launcher.core.LauncherFactory (in unnamed module 
> @0x6eceb130) cannot access class 
> org.junit.platform.commons.util.Preconditions (in module 
> org.junit.platform.commons) because module org.junit.platform.commons does 
> not export org.junit.platform.commons.util to unnamed module @0x6eceb130
> [ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There 
> was an error in the forked process
> [ERROR] java.lang.IllegalAccessError: class 
> org.junit.platform.launcher.core.LauncherFactory (in unnamed module 
> @0x6eceb130) cannot access class 
> org.junit.platform.commons.util.Preconditions (in module 
> org.junit.platform.commons) because module org.junit.platform.commons does 
> not export org.junit.platform.commons.util to unnamed module @0x6eceb130
> [ERROR]       at 
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:656)
> [ERROR]       at 
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
> [ERROR]       at 
> org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
> [ERROR]       at 
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1183)
> [ERROR]       at 
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1011)
> [ERROR]       at 
> org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:857)
> [ERROR]       at 
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
> [ERROR]       at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
> [ERROR]       at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
> [ERROR]       at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
> [ERROR]       at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
> [ERROR]       at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
> [ERROR]       at 
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
> [ERROR]       at 
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
> [ERROR]       at 
> org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
> [ERROR]       at 
> org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
> [ERROR]       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
> [ERROR]       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
> [ERROR]       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
> [ERROR]       at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
> [ERROR]       at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [ERROR]       at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> [ERROR]       at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> [ERROR]       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> [ERROR]       at 
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
> [ERROR]       at 
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
> [ERROR]       at 
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
> [ERROR]       at 
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> [ERROR]       at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [ERROR]       at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> [ERROR]       at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> [ERROR]       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> [ERROR]       at 
> org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
> [ERROR]       at 
> org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
> [ERROR]       at 
> org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:61)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to