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

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

{quote}Now the idea is to:

move WicketTester and Co in wicket-tester module
move all tests from wicket-core/src/test/java to wicket-core-tests module that 
depends on wicket-tester (the dependency to wicket-core will be transitive). 
wicket-core-tests should not be published to Maven Central.
{quote}
Ok, I finally finished the one you suggested: 
[https://github.com/apache/wicket/pull/660] 

Some remarks:
 * The code builds up on [https://github.com/apache/wicket/pull/659], so the 
things mentioned in my latest comment should be reviewed
 * it is sufficient to include wicket-tester in addition to e. g. 
wicket-extensions:

{code:java}
  <dependencies>
    <dependency>
      <groupId>org.apache.wicket</groupId>
      <artifactId>wicket-extensions</artifactId>
      <version>10.0.0-M2-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>org.apache.wicket</groupId>
      <artifactId>wicket-tester</artifactId>
      <version>10.0.0-M2-SNAPSHOT</version>
      <scope>test</scope>   <!-- keep out JUinit from main code -->
    </dependency>
  </dependencies>{code}
 * _wicket-core_
 ** has no more test code in /src/test/java
 * _wicket-tester_
 ** contains the code from wicket-core 
(/src/main/java/org/apache/wicket/util/tester)
 ** depends on wicket-core
 * _wicket-core-tests_
 ** contains the code from wicket-core (/src/test/java)
 ** depends on wicket-tester (and transitively wicket-core)
 ** testing wicket-core-tests requires two things (added as comments in 
pom.xml):
 *** no module-info may be present to fix "The package org.apache.wicket 
conflicts with a package accessible from another module"
 *** useModulePath must be false in maven-compiler-plugin to fix "Can't compile 
test sources when main sources are missing a module descriptor"
(useModulePath is available in maven-compiler-plugin 3.11+, therefore I needed 
to change it's version from 3.10 to 3.11 in main pom.xml)
 * in _all other wicket modules that need testers from wicket-tester_ (e. g. 
WicketTester), wicket-core must be additionally added because wicket-tester 
dependency is only of scope test and wicket-core is thus not added 
transitively. Otherwise we'd have issues like "module not found: 
org.apache.wicket.util, ..."

Now, when comparing this solution with the one yesterday, the tester dependency 
is a bit more intuitive. Drawback is the splitting of code from one into three 
libs.

[~mgrigorov]: I'd like you to ask for reviewing, testing and making a decision 
which one should make it into master (as Eclipse developer I hope at least one 
will make it ;)). Thank you!

> 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