You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2018/06/22 17:59:29 UTC
[maven-compiler-plugin] 04/06: [MCOMPILER-321] Problematic Java 9
modules are silently ignored
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MCOMPILER-323
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
commit c915879f6769dec1c5c9a6df64dd2b0cad7ea28c
Author: rfscholte <rf...@apache.org>
AuthorDate: Wed Jun 6 22:41:13 2018 +0200
[MCOMPILER-321] Problematic Java 9 modules are silently ignored
---
.../invoker.properties | 18 +++++++
src/it/MCOMPILER-321_pathexceptions/pom.xml | 62 ++++++++++++++++++++++
.../src/invoker.properties | 18 +++++++
.../src/main/java/module-info.java | 22 ++++++++
.../src/test/java/test/MyTest.java | 24 +++++++++
src/it/MCOMPILER-321_pathexceptions/verify.groovy | 24 +++++++++
.../apache/maven/plugin/compiler/CompilerMojo.java | 12 +++++
.../maven/plugin/compiler/TestCompilerMojo.java | 16 +++++-
8 files changed, 195 insertions(+), 1 deletion(-)
diff --git a/src/it/MCOMPILER-321_pathexceptions/invoker.properties b/src/it/MCOMPILER-321_pathexceptions/invoker.properties
new file mode 100644
index 0000000..9511718
--- /dev/null
+++ b/src/it/MCOMPILER-321_pathexceptions/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-321_pathexceptions/pom.xml b/src/it/MCOMPILER-321_pathexceptions/pom.xml
new file mode 100644
index 0000000..f5cd0b8
--- /dev/null
+++ b/src/it/MCOMPILER-321_pathexceptions/pom.xml
@@ -0,0 +1,62 @@
+<?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>mcompiler321</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <url>https://issues.apache.org/jira/browse/MCOMPILER-321</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>@project.version@</version>
+ <configuration>
+ <release>9</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_2.4_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/src/it/MCOMPILER-321_pathexceptions/src/invoker.properties b/src/it/MCOMPILER-321_pathexceptions/src/invoker.properties
new file mode 100644
index 0000000..9511718
--- /dev/null
+++ b/src/it/MCOMPILER-321_pathexceptions/src/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-321_pathexceptions/src/main/java/module-info.java b/src/it/MCOMPILER-321_pathexceptions/src/main/java/module-info.java
new file mode 100644
index 0000000..0f43b06
--- /dev/null
+++ b/src/it/MCOMPILER-321_pathexceptions/src/main/java/module-info.java
@@ -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.
+ */
+
+module M.N {
+
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-321_pathexceptions/src/test/java/test/MyTest.java b/src/it/MCOMPILER-321_pathexceptions/src/test/java/test/MyTest.java
new file mode 100644
index 0000000..e2e0835
--- /dev/null
+++ b/src/it/MCOMPILER-321_pathexceptions/src/test/java/test/MyTest.java
@@ -0,0 +1,24 @@
+package 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.
+ */
+
+public class MyTest
+{
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-321_pathexceptions/verify.groovy b/src/it/MCOMPILER-321_pathexceptions/verify.groovy
new file mode 100644
index 0000000..685fbd8
--- /dev/null
+++ b/src/it/MCOMPILER-321_pathexceptions/verify.groovy
@@ -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.
+ */
+def log = new File( basedir, 'build.log').text
+
+assert 2 == log.count( "[WARNING] Can't extract module name from geronimo-servlet_2.4_spec-1.1.1.jar: "
+ /* Invalid module name: '2' is not a Java identifier */ )
+assert 2 == log.count( "[WARNING] Can't extract module name from jdom-1.0.jar: "
+ /* JDOMAbout$Author.class found in top-level directory (unnamed package not allowed in module) */ )
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 46dbabe..1053d7d 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -29,6 +29,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
@@ -237,6 +238,17 @@ public class CompilerMojo
resolvePathsResult = locationManager.resolvePaths( request );
+ for ( Entry<File, Exception> pathException : resolvePathsResult.getPathExceptions().entrySet() )
+ {
+ Throwable cause = pathException.getValue().getCause();
+ while ( cause.getCause() != null )
+ {
+ cause = cause.getCause();
+ }
+ String fileName = pathException.getKey().getName();
+ getLog().warn( "Can't extract module name from " + fileName + ": " + cause.getMessage() );
+ }
+
JavaModuleDescriptor moduleDescriptor = resolvePathsResult.getMainModuleDescriptor();
for ( Map.Entry<File, ModuleNameSource> entry : resolvePathsResult.getModulepathElements().entrySet() )
diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
index 46c6fc0..7fbe75d 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
@@ -30,9 +30,11 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
@@ -159,7 +161,8 @@ public class TestCompilerMojo
@Parameter( defaultValue = "${project.testClasspathElements}", readonly = true )
private List<String> testPath;
- private LocationManager locationManager = new LocationManager();
+ @Component
+ private LocationManager locationManager;
private Map<String, JavaModuleDescriptor> pathElements;
@@ -245,6 +248,17 @@ public class TestCompilerMojo
}
result = locationManager.resolvePaths( request );
+
+ for ( Entry<String, Exception> pathException : result.getPathExceptions().entrySet() )
+ {
+ Throwable cause = pathException.getValue().getCause();
+ while ( cause.getCause() != null )
+ {
+ cause = cause.getCause();
+ }
+ String fileName = Paths.get( pathException.getKey() ).getFileName().toString();
+ getLog().warn( "Can't extract module name from " + fileName + ": " + cause.getMessage() );
+ }
}
catch ( IOException e )
{