Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1531

Option to switch-off Java 9 modules

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.22.0
    • 3.0.0-M2
    • Maven Surefire Plugin
    • None

    Description

      I am working on a library and I am adding support for Java 9 modules. Surefire 2.21.0 by default executes tests with Java 9 modules switched-on if it detects module-info.java While it may make sense in some cases, in my case I'd like the switch it off.

      The reason is simple. I am using Mockito to mock an interface that extends a Spring interface. Mockito has to create an implementation of this interface (proxy or subclass) and for this it needs to have access to the Spring interfaces. If Java 9 modules are enabled for the tests I have to manually add each such dependencies to Surefire configuration, which does not make much sense. To makes things worse, the interface actually extends two Spring interfaces form two different Spring modules so the configuration is almost impossible to get right.

      So far I am at ( and I am still getting IllegalAccessErrors)

      --add-exports spring.context/org.springframework.scheduling=org.mockito
      --add-exports spring.beans/org.springframework.beans.factory=org.mockito
      

      I would prefer to switch-off the Java 9 modules for the test module altogether (same behavior as pre 2.21.0)

       

      The test is here https://github.com/lukas-krecan/ShedLock/blob/java9/shedlock-spring/src/test/java/net/javacrumbs/shedlock/spring/CleanupTest.java

       

      If you want, I can send a pull request.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            tibordigana Tibor Digana
            lukas_krecan Lukáš Křečan
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment