Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testCompile using groovy-eclipse-compiler fails with error about --patch-modules #987

Closed
clarkperkins opened this issue Nov 8, 2019 · 5 comments
Assignees
Labels
Milestone

Comments

@clarkperkins
Copy link

When I add a module-info.java file to my main source set, the testCompile mojo fails with this error:

[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ artifactid ---
[INFO] Changes detected - recompiling the module!
[INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
[INFO] Unrecognized option : --patch-module
[INFO] Found 0 errors and 0 warnings.

I'm currently using javac for my main sources, and groovy-eclipse for my test sources.

Environment details:
java: 11.0.5
maven: 3.6.2
maven-compiler-plugin: 3.8.1
groovy-eclipse-compiler: 3.6.0-01
groovy-eclipse-batch: 2.5.8-02

@eric-milles
Copy link
Member

Could you enable verbose setting on the compiler and include the command line arguments being passed to groovy-eclipse-batch?

@clarkperkins
Copy link
Author

sure! I don't have any compilerArgs set on the maven-compiler-plugin. Here's my maven-compiler-plugin config:

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <release>11</release>
                    <parameters>true</parameters>
                </configuration>
				<executions>
					<execution>
						<id>default-testCompile</id>
						<configuration>
							<compilerId>groovy-eclipse-compiler</compilerId>
						</configuration>
					</execution>
				</executions>
				<dependencies>
					<dependency>
						<groupId>org.codehaus.groovy</groupId>
						<artifactId>groovy-eclipse-compiler</artifactId>
						<version>3.6.0-01</version>
					</dependency>
					<dependency>
						<groupId>org.codehaus.groovy</groupId>
						<artifactId>groovy-eclipse-batch</artifactId>
						<version>2.5.8-02</version>
					</dependency>
				</dependencies>
            </plugin>

and here's the verbose output:

[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ utils-classloader ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-compiler-plugin:3.8.1, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@277050dc]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile' with basic configurator -->
[DEBUG]   (f) basedir = /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader
[DEBUG]   (f) buildDirectory = /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target
[DEBUG]   (f) compilePath = [/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes, /Users/clark.perkins/.m2/repository/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar]
[DEBUG]   (f) compileSourceRoots = [/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java]
[DEBUG]   (f) compilerId = groovy-eclipse-compiler
[DEBUG]   (f) debug = true
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) failOnError = true
[DEBUG]   (f) failOnWarning = false
[DEBUG]   (f) forceJavacCompilerUse = false
[DEBUG]   (f) fork = false
[DEBUG]   (f) generatedTestSourcesDirectory = /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/generated-test-sources/test-annotations
[DEBUG]   (f) mojoExecution = org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile {execution: default-testCompile}
[DEBUG]   (f) optimize = false
[DEBUG]   (f) outputDirectory = /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes
[DEBUG]   (f) parameters = true
[DEBUG]   (f) project = MavenProject: com.digitalreasoning.synthesys.kernel.utils:utils-classloader:2.0.0-java11-SNAPSHOT @ /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/pom.xml
[DEBUG]   (s) release = 11
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@3c88191b
[DEBUG]   (f) showDeprecation = false
[DEBUG]   (f) showWarnings = false
[DEBUG]   (f) skipMultiThreadWarning = false
[DEBUG]   (f) source = 11
[DEBUG]   (f) staleMillis = 0
[DEBUG]   (s) target = 11
[DEBUG]   (f) testPath = [/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes, /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes, /Users/clark.perkins/.m2/repository/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar, /Users/clark.perkins/.m2/repository/org/spockframework/spock-core/1.3-groovy-2.5/spock-core-1.3-groovy-2.5.jar, /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy/2.5.8/groovy-2.5.8.jar, /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-json/2.5.8/groovy-json-2.5.8.jar, /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-nio/2.5.8/groovy-nio-2.5.8.jar, /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-macro/2.5.8/groovy-macro-2.5.8.jar, /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-templates/2.5.4/groovy-templates-2.5.4.jar, /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-test/2.5.4/groovy-test-2.5.4.jar, /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-sql/2.5.8/groovy-sql-2.5.8.jar, /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-xml/2.5.8/groovy-xml-2.5.8.jar, /Users/clark.perkins/.m2/repository/junit/junit/4.12/junit-4.12.jar, /Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar, /Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar, /Users/clark.perkins/.m2/repository/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar]
[DEBUG]   (f) useIncrementalCompilation = true
[DEBUG]   (f) verbose = true
[DEBUG] -- end configuration --
[DEBUG] Using compiler 'groovy-eclipse-compiler'.
[DEBUG] Adding /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/generated-test-sources/test-annotations to test-compile source roots:
  /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java
[DEBUG] New test-compile source roots:
  /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java
  /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/generated-test-sources/test-annotations
[DEBUG] CompilerReuseStrategy: reuseCreated
[DEBUG] useIncrementalCompilation enabled
[DEBUG] New dependency detected: /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes
[INFO] Changes detected - recompiling the module!
[DEBUG] Classpath:
[DEBUG]  /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes
[DEBUG]  /Users/clark.perkins/.m2/repository/org/spockframework/spock-core/1.3-groovy-2.5/spock-core-1.3-groovy-2.5.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy/2.5.8/groovy-2.5.8.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-json/2.5.8/groovy-json-2.5.8.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-nio/2.5.8/groovy-nio-2.5.8.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-macro/2.5.8/groovy-macro-2.5.8.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-templates/2.5.4/groovy-templates-2.5.4.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-test/2.5.4/groovy-test-2.5.4.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-sql/2.5.8/groovy-sql-2.5.8.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-xml/2.5.8/groovy-xml-2.5.8.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/junit/junit/4.12/junit-4.12.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar
[DEBUG]  /Users/clark.perkins/.m2/repository/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar
[DEBUG] Modulepath:
[DEBUG]  /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes
[DEBUG]  /Users/clark.perkins/.m2/repository/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar
[DEBUG] Source roots:
[DEBUG]  /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java
[DEBUG]  /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/generated-test-sources/test-annotations
[INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
[DEBUG] Compiling 2 source files to /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes
[INFO] Classpath: /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes:/Users/clark.perkins/.m2/repository/org/spockframework/spock-core/1.3-groovy-2.5/spock-core-1.3-groovy-2.5.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy/2.5.8/groovy-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-json/2.5.8/groovy-json-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-nio/2.5.8/groovy-nio-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-macro/2.5.8/groovy-macro-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-templates/2.5.4/groovy-templates-2.5.4.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-test/2.5.4/groovy-test-2.5.4.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-sql/2.5.8/groovy-sql-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-xml/2.5.8/groovy-xml-2.5.8.jar:/Users/clark.perkins/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar:/Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/clark.perkins/.m2/repository/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar:
[INFO] Modulepath: /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes:/Users/clark.perkins/.m2/repository/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar:
[DEBUG] Command line options:
[DEBUG] -verbose -cp /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes:/Users/clark.perkins/.m2/repository/org/spockframework/spock-core/1.3-groovy-2.5/spock-core-1.3-groovy-2.5.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy/2.5.8/groovy-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-json/2.5.8/groovy-json-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-nio/2.5.8/groovy-nio-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-macro/2.5.8/groovy-macro-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-templates/2.5.4/groovy-templates-2.5.4.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-test/2.5.4/groovy-test-2.5.4.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-sql/2.5.8/groovy-sql-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-xml/2.5.8/groovy-xml-2.5.8.jar:/Users/clark.perkins/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar:/Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/clark.perkins/.m2/repository/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar: -p /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes:/Users/clark.perkins/.m2/repository/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar: -d /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes -s /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/generated-test-sources/test-annotations -g -encoding UTF-8 --release 11 -nowarn -parameters --patch-module -synthesys.kernel.utils.classloader=/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes:/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java:/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/generated-test-sources/test-annotations: --add-reads -synthesys.kernel.utils.classloader=ALL-UNNAMED /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java/synthesys/kernel/utils/classloader/FilterClassLoaderTest.groovy /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java/synthesys/kernel/utils/classloader/MultiplexingClassLoaderTest.groovy
[DEBUG] incrementalBuildHelper#beforeRebuildExecution
[INFO] Looking for sources in source root: /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java
[INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files
[DEBUG] Compiling 2 source files to /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes
[INFO] Classpath: /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes:/Users/clark.perkins/.m2/repository/org/spockframework/spock-core/1.3-groovy-2.5/spock-core-1.3-groovy-2.5.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy/2.5.8/groovy-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-json/2.5.8/groovy-json-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-nio/2.5.8/groovy-nio-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-macro/2.5.8/groovy-macro-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-templates/2.5.4/groovy-templates-2.5.4.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-test/2.5.4/groovy-test-2.5.4.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-sql/2.5.8/groovy-sql-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-xml/2.5.8/groovy-xml-2.5.8.jar:/Users/clark.perkins/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar:/Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/clark.perkins/.m2/repository/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar:
[INFO] Modulepath: /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes:/Users/clark.perkins/.m2/repository/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar:
[INFO] Compiler arguments: [-verbose, -cp, /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes:/Users/clark.perkins/.m2/repository/org/spockframework/spock-core/1.3-groovy-2.5/spock-core-1.3-groovy-2.5.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy/2.5.8/groovy-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-json/2.5.8/groovy-json-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-nio/2.5.8/groovy-nio-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-macro/2.5.8/groovy-macro-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-templates/2.5.4/groovy-templates-2.5.4.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-test/2.5.4/groovy-test-2.5.4.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-sql/2.5.8/groovy-sql-2.5.8.jar:/Users/clark.perkins/.m2/repository/org/codehaus/groovy/groovy-xml/2.5.8/groovy-xml-2.5.8.jar:/Users/clark.perkins/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest-core/2.2/hamcrest-core-2.2.jar:/Users/clark.perkins/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/Users/clark.perkins/.m2/repository/cglib/cglib-nodep/3.3.0/cglib-nodep-3.3.0.jar:, -p, /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes:/Users/clark.perkins/.m2/repository/org/slf4j/slf4j-api/1.7.29/slf4j-api-1.7.29.jar:, -d, /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/test-classes, -s, /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/generated-test-sources/test-annotations, -g, -encoding, UTF-8, --release, 11, -nowarn, -parameters, --patch-module, -synthesys.kernel.utils.classloader=/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/classes:/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java:/Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/target/generated-test-sources/test-annotations:, --add-reads, -synthesys.kernel.utils.classloader=ALL-UNNAMED, /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java/synthesys/kernel/utils/classloader/FilterClassLoaderTest.groovy, /Users/clark.perkins/Workspace/platform/kernel/utils/utils-classloader/src/test/java/synthesys/kernel/utils/classloader/MultiplexingClassLoaderTest.groovy]
[INFO] Compilation complete.  Compiled 0 files.
[DEBUG] incrementalBuildHelper#afterRebuildExecution
[INFO] Unrecognized option : --patch-module
[INFO] Found 0 errors and 0 warnings.
[INFO] --------------------------------

@eric-milles
Copy link
Member

So, it looks like the following arguments are being passed (besides source files to compile):

-verbose
-cp
...
-d
<output directory>
-s
<sources (generated) directory>
-g
-encoding
UTF-8
--release
11
-nowarn
-parameters
--patch-module
-synthesys.kernel.utils.classloader=...
--add-reads
-synthesys.kernel.utils.classloader=ALL-UNNAMED

groovy-eclipse-batch understands these command-line arguments: https://help.eclipse.org/2019-09/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_batch_compiler.htm

--patch-module is not one of the available arguments. It also looks like the add-reads and patch-module arguments are getting an extra dash added to them.

@eric-milles
Copy link
Member

At the end of org.codehaus.groovy.eclipse.compiler.GroovyEclipseCompiler#createCommandLine you can replace the last for loop with this:

        String prev = null;
        for (Map.Entry<String, String> entry : config.getCustomCompilerArgumentsAsMap().entrySet()) {
            String key = entry.getKey();
            if (key.startsWith("-")) {
                if ("-javaAgentClass".equals(key)) {
                    setJavaAgentClass(entry.getValue());
                } else if (!key.startsWith("-J")) {
                    args.put(key, entry.getValue());
                } else {
                    vmArgs.add(key.substring(2));
                }
                prev = (entry.getValue() == null ? key : null);
            } else {
                if (prev != null && entry.getValue() == null) {
                    args.put(prev, key);
                } else if (!"org.osgi.framework.system.packages".equals(key)) { // GRECLIPSE-1418: ignore the system packages option
                    args.put("-" + key, entry.getValue());
                }
                prev = null;
            }
        }
        args.remove("--patch-module"); // https://github.com/groovy/groovy-eclipse/issues/987

Then you can run "mvn install" from the extras/groovy-eclipse-compiler directory to add 3.6.0-SNAPSHOT to your local m2 repository.

@eric-milles eric-milles self-assigned this Nov 8, 2019
eric-milles added a commit that referenced this issue Dec 9, 2019
skip unsupported "--patch-module" command-line argument

#987
@eric-milles
Copy link
Member

@eric-milles eric-milles added this to the v3.6.0 milestone Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants