You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2019/03/23 14:00:23 UTC

[maven-compiler-plugin] branch MCOMPILER-366 updated (783cb1e -> 3d6b27c)

This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a change to branch MCOMPILER-366
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git.


 discard 783cb1e  [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
     add d8bfa28  Make unit/integration tests Java 12 compatible
     new 3d6b27c  [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

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (783cb1e)
            \
             N -- N -- N   refs/heads/MCOMPILER-366 (3d6b27c)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[maven-compiler-plugin] 01/01: [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

Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MCOMPILER-366
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git

commit 3d6b27cc81c3dde2d537ca3be1117d470d0017f3
Author: Oscar Farga <os...@netcentric.biz>
AuthorDate: Mon Jan 14 23:08:21 2019 +0100

    [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
---
 src/it/MCOMPILER-366/invoker.properties            | 18 +++++++
 src/it/MCOMPILER-366/pom.xml                       | 61 ++++++++++++++++++++++
 .../src/main/java/module-info.java}                | 46 ++++++++--------
 .../src/main/java/org/maven/test/Main.java}        | 56 ++++++++++++--------
 .../verify.groovy                                  | 44 ++++++++--------
 src/it/automodules-application/verify.groovy       |  2 +-
 src/it/automodules-library/verify.groovy           |  2 +-
 src/it/automodules-transitive-module/verify.groovy |  2 +-
 .../apache/maven/plugin/compiler/CompilerMojo.java | 52 +++++++++++-------
 9 files changed, 194 insertions(+), 89 deletions(-)

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/automodules-application/verify.groovy b/src/it/MCOMPILER-366/src/main/java/module-info.java
similarity index 78%
copy from src/it/automodules-application/verify.groovy
copy to src/it/MCOMPILER-366/src/main/java/module-info.java
index 4ce088d..95e7266 100644
--- a/src/it/automodules-application/verify.groovy
+++ b/src/it/MCOMPILER-366/src/main/java/module-info.java
@@ -1,22 +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.
- */
-
-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!");
+/*
+ * 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/automodules-application/verify.groovy b/src/it/MCOMPILER-366/src/main/java/org/maven/test/Main.java
similarity index 70%
copy from src/it/automodules-application/verify.groovy
copy to src/it/MCOMPILER-366/src/main/java/org/maven/test/Main.java
index 4ce088d..f2c4a2f 100644
--- a/src/it/automodules-application/verify.groovy
+++ b/src/it/MCOMPILER-366/src/main/java/org/maven/test/Main.java
@@ -1,22 +1,34 @@
-/*
- * 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("[INFO] Required filename-based automodules detected. Please don't publish this project to a public artifact repository!");
+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/automodules-library/verify.groovy b/src/it/MCOMPILER-366/verify.groovy
similarity index 86%
copy from src/it/automodules-library/verify.groovy
copy to src/it/MCOMPILER-366/verify.groovy
index fb2d1d1..c5a90ad 100644
--- a/src/it/automodules-library/verify.groovy
+++ b/src/it/MCOMPILER-366/verify.groovy
@@ -1,22 +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. Please don't publish this project to a public artifact repository! *");
+/*
+ * 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 @@ public class CompilerMojo
                 
                 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 @@ public class CompilerMojo
             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 )
     {