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

Tibor Digana commented on SUREFIRE-1811:
----------------------------------------

[~Pavel_K]

See my first comment again please #comment-17146548
I do not know how it is possible that you do not understand basic things which 
are the first you have to check when you see the issue like this. It does not 
have to be mentioned in detail but now i have to do it. You did not export 
packages from {{src/main/java/module-info.java}}
and therefore missing {{exports com.foo.hibernate.h2.test4}},
and you did not import them via {{requires transitive 
com.foo.hibernate.h2.test4}} in {{src/test/java/module-info.java}}.
One has to notice that you have all packages the same in both modules which 
does not make logical sense in JPMS.
Both modules are named the same {{HibernateH2Test4}} and they have the same 
package {{com.foo.hibernate.h2.test4}}.
Yes, they are two modules, they are separate bunch of sources and have separate 
{{module-info.java}}.
It is no magic, we do not make any magic, and you can see the Java command for 
JVM if you run the build in debug mode with {{-X}}, and there you will see a 
trivial command which you can run for whatever commandline application:
{{java --module-path <all jar files here>> --class-path <<surefire jar files>> 
--add-module <<test module name>> 
org.apache.maven.surefire.booter.ForkedBooter}} 
We don't mean file name by module name, as you guys were discussion above.
It does not make sense to talk about {{module-info.test.java}} - this is 
political agenda of Christian where he preferably wanted to segregate 
compilation descriptor from test runtime descriptor. We use the standard names 
and changing them does not solve your problem. Solve your problem as i said, 
three changes must be done by your, and then it will work and I can prove it by 
our integration test, and the 4th change i did not mantion is to make you main 
module {{open}} otherwise the resources would not be found, see the [Javadoc in 
JDK|https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html#getResourceAsStream(java.lang.String)]
*null if no resource with this name is found, the resource is in a package that 
is not open to at least the caller module*
and here is our [integration 
test|https://github.com/apache/maven-surefire/tree/surefire-1733-junit4/surefire-its/src/test/resources/surefire-1733-junit4].
 Execute it via {{mvn verify -Dsurefire.version=3.0.0-M5}}!
You can clearly see that we are loading all ways of resources, and yes it was 
problem without having open module, but i am not a JPMS guru, all i do is 
reading the Javadoc in JDK. If you was more critical to your code, you would 
find it and we did not spend 3 hours with preparing the specific IT for you!

> Add resources to JPMS test module
> ---------------------------------
>
>                 Key: SUREFIRE-1811
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1811
>             Project: Maven Surefire
>          Issue Type: New Feature
>          Components: Maven Failsafe Plugin
>    Affects Versions: 3.0.0-M5
>            Reporter: Pavel_K
>            Priority: Major
>
> I am testing version 3.0.0-M5 with two module-info in one project - one main 
> and one for test. My test project is here 
> https://github.com/PashaTurok/hibernate-h2-test4 . The problem is with 
> resources. For example, I have  src/main/resources/META-INF/persistence.xml 
> file that is not copied to test module. Because of this it is not possible to 
> find resource in test module and it is necessary to use something like this 
> https://github.com/PashaTurok/hibernate-h2-test4/blob/292e2e683ad72487cbf8d2e5a35dde0d9255001a/src/test/java/com/foo/hibernate/h2/test4/TestIT.java#L72
>  . 
> In target/test-classes/META-INF/jpms.args I see:
> {code:java}
> --patch-module
> my.project=/home/..../hibernate-h2-test4/src/main/java, 
> /home/.../hibernate-h2-test4/target/generated-sources/annotations
> {code}
> As I understand test module will NOT contain resources from the module under 
> test? I mean that test module will NOT contain 
> /home/..../hibernate-h2-test4/src/main/resources? 
> That's why I suggest to include src/main/resources in test module.



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

Reply via email to