Uploaded image for project: 'Maven Compiler Plugin'
  1. Maven Compiler Plugin
  2. MCOMPILER-336

Dependency that should be on modulepath sometime put on classpath

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.7.0
    • 3.8.0
    • None

    Description

      maven-compiler-plugin sometime puts modularized dependencies on the javac -classpath option instead than -modulepath, which cause compilation failure. A test case is attached. Step to reproduce:

      cd module-vs-classpath
      cd a
      mvn install
      cd ../b
      mvn clean install
      mvn install
      

      The last command fail with the following error message:

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project b: Compilation failure
      [ERROR] module not found: test.a
      

      Execution with the -X option shows that the test.a dependency is correctly declared in -modulepath when executing mvn clean install, but is wrongly declared in -classpath when executing mvn install.

      A workaround is to remove the <useIncrementalCompilation>false</useIncrementalCompilation> option in the pom.xml files, or to execute touch src/main/java/module-info.java before mvn install. However the same error message occurs when attempting to execute mvn site, for which case I have found no workaround yet (note: the mvn site problem is not reproduced by the attached module-vs-classpath.zip file).

      Attachments

        1. module-vs-classpath.zip
          4 kB
          Martin Desruisseaux

        Activity

          People

            rfscholte Robert Scholte
            desruisseaux Martin Desruisseaux
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: