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

Sam Peters commented on WICKET-7072:
------------------------------------

[~hobrom]: Yes, it was a typo and should be "false". But the value did not make 
a difference for me, the described error remains. I wonder if Eclipse actually 
cares about the config of the surefire plugin in pom.xml?

[~mgrigorov]: Ok, I cloned wicket, imported _wicket-util_ as project in 
Eclipse, added the _static_ keyword to _org.junit.jupiter.api in_ wicket-util's 
module-info, linked the code in my project and ran it. Still the same error. 
That is, _requires static_ does not seem to solve the issue for me.

The problem seems really to be with putting JUnit code in _/src/main/java._ 
Which at least confuses Eclipse IDE.

Thus, the remaining approach would be, in my eyes, to separate JUnit code from 
{_}/src/main/java{_}. This is basically the idea of WICKET-7019, but 
unfortunately, the fork linked there is not available anymore. I tried a 
restart and would like to throw in some ideas to make refactoring simple for 
users:
 * separation of wicket-core:
 ** create an new lib, e. g. wicket-core-test
 ** move the complete package _org.apache.wicket.util.tester_ from wicket-core 
to wicket-core-test (both for src/main/java and src/test/java). A few test 
classes must be also copied/moved from _src/test/java/org/apache/wicket_
 * separation of wicket-util:
 ** create an new lib, e. g. wicket-util-test
 ** move the complete packages _org.apache.wicket.util.license_ and 
_org.apache.wicket.util.markup.xhtml_ from wicket-util to wicket-util-test 
(both for src/main/java and src/test/java).
 * adaptions in wicket-core and wicket-util:
 ** remove (untypical) _requires_ _org.junit.jupiter.api_ and change JUnit to 
(typical) scope "test"
 * adaptions in wicket-core-test and wicket-util-test:
 ** add _requires org.junit.jupiter.api_ and change JUnit to scope "compile"

With this new setting, projects that requires tester methods (like 
WicketTester) could now additionally add wicket-core-test and/or 
wicket-util-test with scope test (no modifications of module-info required). 
All other projects wont' see any JUnit-related classes in /src/main/java 
anymore and the issue should be fixed (some local tests confirmed that which 
corresponds also to WICKET-7019).

Moving complete packages as shown above...
 * seems to be unproblematic since the code moved has no relevant references 
(in the libraries themselves)
 * package naming clashes are avoided
 * refactoring/renaming packages is not necessary in user's code since the 
package names remain.

What do you think?

> JUnit code in /src/main/java breaks JPMS support in Eclipse IDE
> ---------------------------------------------------------------
>
>                 Key: WICKET-7072
>                 URL: https://issues.apache.org/jira/browse/WICKET-7072
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-core
>    Affects Versions: 10.0.0-M1
>            Reporter: Sam Peters
>            Priority: Major
>
> In Wicket 10, the wicket-core and wicket-util jars contain JUnit-related 
> code, see class list below.
> The problem:
>  * When creating a new modular (JPMS) maven project by adding __ just 
> _org.apache.wicket.commons.fileupload_ ({_}not containing{_} JUnit code) in 
> {_}module-info{_}, projects run fine in Eclipse IDE (2023-06). I supplied a 
> quickstarter at 
> [https://github.com/gluser1357/jerseyissues/tree/main-without-junit-code], 
> see readme.txt.
>  * In contrast, when creating a new modular project by adding 
> {_}org.apache.wicket.util{_}" ({_}containing{_} JUnit code), Eclipse fails in 
> different ways, see wicket quickstarter at 
> [https://github.com/gluser1357/jerseyissues/tree/main-with-junit-code-error], 
> see readme.txt.
>  ** If JUnit is kept with usual _<scope>test<scope>_ (pom.xml) and not added 
> via _requires org.junit.jupiter.api_ in module-info.java, one of the 
> following errors occur when running code (see readme.txt for more details):
>  *** _java.lang.module.FindException: Module org.junit.jupiter.api not found, 
> required by org.apache.wicket.util_
>  *** _java.lang.Error: Unresolved compilation problem: "The type 
> org.junit.jupiter.api.Test is not accessible"_
>  *** _java.lang.IllegalAccessError: class 
> org.junit.platform.launcher.core.ServiceLoaderRegistry (in unnamed module 
> @0x5f341870) cannot access class 
> org.junit.platform.commons.logging.LoggerFactory (in module 
> org.junit.platform.commons) because module org.junit.platform.commons does 
> not export org.junit.platform.commons.logging to unnamed module @0x5f341870_  
>  
>  ** After correcting the missing module and dependency by removing 
> _<scope>test<scope>_ (pom.xml) and adding a _requires org.junit.jupiter.api_ 
> in module-info.java (which is, as far as I know, actually untypical), own 
> code in _/src/test/java_ and _/src/main/java_ runs now, but own JUnit tests 
> can still not be executed via "Run As JUnit Test" in Eclipse because of
>  *** _java.lang.IllegalAccessError: class 
> org.junit.platform.launcher.core.ServiceLoaderRegistry (in unnamed module 
> @0x5f341870) cannot access class 
> org.junit.platform.commons.logging.LoggerFactory (in module 
> org.junit.platform.commons) because module org.junit.platform.commons does 
> not export org.junit.platform.commons.logging to unnamed module @0x5f341870_  
>  
> In my opinion, the JUnit-related code below shouldn't be contained in 
> _/src/main/java_ which is a) quite untypical and b) results in problems of 
> common IDEs like Eclipse.
> *Would it be possible to*
>  * *move the related Wicket classes (see list below) out of 
> {_}/src/main/java{_}, e. g. to _/src/test/java_ and*
>  * *remove _requires org.junit.jupiter.api_ from both module-info?*
> This would avoid these problems in Eclipse IDE for JPMS-based projects that 
> want to integrate Wicket.
> =====
> The relevant classes are:
>  * in wicket-util:
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-util/src/main/java/org/apache/wicket/util/license/ApacheLicenseHeaderTestCase.java]
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-util/src/main/java/org/apache/wicket/util/markup/xhtml/WellFormedXmlTestCase.java]
>  * in wicket-core:
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java]
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-core/src/main/java/org/apache/wicket/util/tester/DiffUtil.java]
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-core/src/main/java/org/apache/wicket/util/tester/FormTester.java]
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTestCase.java]
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java]
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTesterExtension.java]
>  ** 
> [https://github.com/apache/wicket/blob/rel/wicket-10.0.0-M1/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTesterHelper.java]
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to