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

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

commit 0c28f120ba89e3861490efdc1cb0aa35fb822f95
Author: rfscholte <rfscho...@apache.org>
AuthorDate: Sun Mar 11 21:18:48 2018 +0100

    [MCOMPILER-321] Problematic Java 9 modules are silently ignored
---
 pom.xml                                            |  2 +-
 .../invoker.properties                             | 19 ++++++++
 src/it/MCOMPILER-321_module-warning/pom.xml        | 56 ++++++++++++++++++++++
 .../src/main/java/module-info.java                 | 21 ++++++++
 src/it/MCOMPILER-321_module-warning/verify.groovy  | 26 ++++++++++
 .../apache/maven/plugin/compiler/CompilerMojo.java | 23 +++++++++
 6 files changed, 146 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 9540d68..b9fc4ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -119,7 +119,7 @@ under the License.
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-java</artifactId>
-      <version>0.9.4</version>
+      <version>0.9.6</version>
     </dependency>
 
     <dependency>
diff --git a/src/it/MCOMPILER-321_module-warning/invoker.properties 
b/src/it/MCOMPILER-321_module-warning/invoker.properties
new file mode 100644
index 0000000..1e66566
--- /dev/null
+++ b/src/it/MCOMPILER-321_module-warning/invoker.properties
@@ -0,0 +1,19 @@
+# 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 = 1.9+
+invoker.buildResult = failure
diff --git a/src/it/MCOMPILER-321_module-warning/pom.xml 
b/src/it/MCOMPILER-321_module-warning/pom.xml
new file mode 100644
index 0000000..cf7c68e
--- /dev/null
+++ b/src/it/MCOMPILER-321_module-warning/pom.xml
@@ -0,0 +1,56 @@
+<?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/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins.compiler.it</groupId>
+  <artifactId>mcompiler321</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+
+  <url>https://issues.apache.org/jira/browse/MCOMPILER-298</url>
+   
+  <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.python</groupId>
+      <artifactId>jython-standalone</artifactId>
+      <version>2.7.0</version>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/src/it/MCOMPILER-321_module-warning/src/main/java/module-info.java 
b/src/it/MCOMPILER-321_module-warning/src/main/java/module-info.java
new file mode 100644
index 0000000..b9e0928
--- /dev/null
+++ b/src/it/MCOMPILER-321_module-warning/src/main/java/module-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 nl.meandi.test {
+    requires jython.standalone;
+}
diff --git a/src/it/MCOMPILER-321_module-warning/verify.groovy 
b/src/it/MCOMPILER-321_module-warning/verify.groovy
new file mode 100644
index 0000000..1271975
--- /dev/null
+++ b/src/it/MCOMPILER-321_module-warning/verify.groovy
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+def warnLines = new File( basedir, 'build.log').readLines()
+                                               .dropWhile{ it != "[WARNING] 
Can't extract module name from the following entries:" }
+                                               .takeWhile{ 
!it.startsWith("[DEBUG]") }
+
+def expectedLines = [ "[WARNING] Can't extract module name from the following 
entries:",
+                     "  - jython-standalone-2.7.0.jar: 
ProxyDeserialization.class found in top-level directory (unnamed package not 
allowed in module)" ] as LinkedList
+
+assert warnLines == expectedLines
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 d1956ae..04a63e9 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -218,6 +218,29 @@ public class CompilerMojo
 
                 resolvePathsResult = locationManager.resolvePaths( request );
                 
+                Map<File, Exception> pathExceptions = 
resolvePathsResult.getPathExceptions();
+                if ( !pathExceptions.isEmpty() )
+                {
+                    final String ls = System.getProperty( "line.separator" );
+
+                    StringBuilder sb = new StringBuilder( "Can't extract 
module name from the following entries:" );
+                  
+                    for ( Map.Entry<File, Exception> pathException : 
resolvePathsResult.getPathExceptions().entrySet() )
+                    {
+                        Throwable cause = pathException.getValue();
+
+                        while ( cause.getCause() != null )
+                        {
+                            cause = cause.getCause();
+                        }
+
+                        sb.append( ls ).append( "  - " ).append( 
pathException.getKey().getName() ).append( ": " )
+                            .append( cause.getMessage() );
+                    }
+                    
+                    getLog().warn( sb );
+                }
+
                 JavaModuleDescriptor moduleDescriptor = 
resolvePathsResult.getMainModuleDescriptor();
 
                 for ( Map.Entry<File, ModuleNameSource> entry : 
resolvePathsResult.getModulepathElements().entrySet() )

-- 
To stop receiving notification emails like this one, please contact
rfscho...@apache.org.

Reply via email to