Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-7072

JUnit code in /src/main/java breaks JPMS support in Eclipse IDE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 10.0.0-M1
    • 10.0.0-M2
    • wicket-core
    • None

    Description

      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:

       

      Attachments

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              gluser1357 Sam Peters
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: