[MCOMPILER 366] - Warning about automodules should provide the list of offending libraries
- Collected filename based automodules detected and added to the log message.
- Updated unit tests accordingly.
- Added new integration test with 2 modules.
- Make unit/integration tests Java 12 compatible
diff --git a/src/it/MCOMPILER-366/invoker.properties b/src/it/MCOMPILER-366/invoker.properties
new file mode 100644
index 0000000..9511718
--- /dev/null
+++ b/src/it/MCOMPILER-366/invoker.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.java.version = 9+
diff --git a/src/it/MCOMPILER-366/pom.xml b/src/it/MCOMPILER-366/pom.xml
new file mode 100644
index 0000000..35444fc
--- /dev/null
+++ b/src/it/MCOMPILER-366/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.compiler.it</groupId>
+ <artifactId>mcompiler-366</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <release>9</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-resources</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/src/it/MCOMPILER-366/src/main/java/module-info.java b/src/it/MCOMPILER-366/src/main/java/module-info.java
new file mode 100644
index 0000000..95e7266
--- /dev/null
+++ b/src/it/MCOMPILER-366/src/main/java/module-info.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+module lib
+{
+ requires plexus.utils;
+ requires plexus.resources;
+ exports org.maven.test;
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-366/src/main/java/org/maven/test/Main.java b/src/it/MCOMPILER-366/src/main/java/org/maven/test/Main.java
new file mode 100644
index 0000000..f2c4a2f
--- /dev/null
+++ b/src/it/MCOMPILER-366/src/main/java/org/maven/test/Main.java
@@ -0,0 +1,34 @@
+package org.maven.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.resource.ResourceManager;
+
+public class Main {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ System.out.println( StringUtils.concatenate( args ) );
+ ResourceManager manager = null;
+ }
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-366/verify.groovy b/src/it/MCOMPILER-366/verify.groovy
new file mode 100644
index 0000000..c5a90ad
--- /dev/null
+++ b/src/it/MCOMPILER-366/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+buildLog = new File( basedir, 'build.log' ).text;
+
+assert buildLog.contains("[WARNING] * Required filename-based automodules detected: [plexus-utils-2.0.4.jar, plexus-resources-1.1.0.jar]. Please don't publish this project to a public artifact repository! *");
diff --git a/src/it/automodules-application/verify.groovy b/src/it/automodules-application/verify.groovy
index 4ce088d..7f2654b 100644
--- a/src/it/automodules-application/verify.groovy
+++ b/src/it/automodules-application/verify.groovy
@@ -19,4 +19,4 @@
buildLog = new File( basedir, 'build.log' ).text;
-assert buildLog.contains("[INFO] Required filename-based automodules detected. Please don't publish this project to a public artifact repository!");
+assert buildLog.contains("[INFO] Required filename-based automodules detected: [plexus-utils-2.0.4.jar]. Please don't publish this project to a public artifact repository!");
diff --git a/src/it/automodules-library/verify.groovy b/src/it/automodules-library/verify.groovy
index fb2d1d1..6a014a5 100644
--- a/src/it/automodules-library/verify.groovy
+++ b/src/it/automodules-library/verify.groovy
@@ -19,4 +19,4 @@
buildLog = new File( basedir, 'build.log' ).text;
-assert buildLog.contains("[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *");
+assert buildLog.contains("[WARNING] * Required filename-based automodules detected: [plexus-utils-2.0.4.jar]. Please don't publish this project to a public artifact repository! *");
diff --git a/src/it/automodules-transitive-module/verify.groovy b/src/it/automodules-transitive-module/verify.groovy
index fb2d1d1..6a014a5 100644
--- a/src/it/automodules-transitive-module/verify.groovy
+++ b/src/it/automodules-transitive-module/verify.groovy
@@ -19,4 +19,4 @@
buildLog = new File( basedir, 'build.log' ).text;
-assert buildLog.contains("[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *");
+assert buildLog.contains("[WARNING] * Required filename-based automodules detected: [plexus-utils-2.0.4.jar]. Please don't publish this project to a public artifact repository! *");
diff --git a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
index 568b063..8bc437b 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -250,26 +250,7 @@
JavaModuleDescriptor moduleDescriptor = resolvePathsResult.getMainModuleDescriptor();
- for ( Map.Entry<File, ModuleNameSource> entry : resolvePathsResult.getModulepathElements().entrySet() )
- {
- if ( ModuleNameSource.FILENAME.equals( entry.getValue() ) )
- {
- final String message = "Required filename-based automodules detected. "
- + "Please don't publish this project to a public artifact repository!";
-
- if ( moduleDescriptor.exports().isEmpty() )
- {
- // application
- getLog().info( message );
- }
- else
- {
- // library
- writeBoxedWarning( message );
- }
- break;
- }
- }
+ detectFilenameBasedAutomodules( resolvePathsResult, moduleDescriptor );
for ( Map.Entry<File, JavaModuleDescriptor> entry : resolvePathsResult.getPathElements().entrySet() )
{
@@ -324,6 +305,37 @@
modulepathElements = Collections.emptyList();
}
}
+
+ private void detectFilenameBasedAutomodules( final ResolvePathsResult<File> resolvePathsResult,
+ final JavaModuleDescriptor moduleDescriptor )
+ {
+ List<String> automodulesDetected = new ArrayList<>();
+ for ( Entry<File, ModuleNameSource> entry : resolvePathsResult.getModulepathElements().entrySet() )
+ {
+ if ( ModuleNameSource.FILENAME.equals( entry.getValue() ) )
+ {
+ automodulesDetected.add( entry.getKey().getName() );
+ }
+ }
+
+ if ( !automodulesDetected.isEmpty() )
+ {
+ final String message = "Required filename-based automodules detected: "
+ + automodulesDetected + ". "
+ + "Please don't publish this project to a public artifact repository!";
+
+ if ( moduleDescriptor.exports().isEmpty() )
+ {
+ // application
+ getLog().info( message );
+ }
+ else
+ {
+ // library
+ writeBoxedWarning( message );
+ }
+ }
+ }
private List<File> getCompileClasspathElements( MavenProject project )
{