You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gb...@apache.org on 2017/06/18 18:00:24 UTC

svn commit: r1799110 - in /maven/plugins/trunk/maven-dependency-plugin/src: it/projects/mdep-571-list-java9/ main/java/org/apache/maven/plugins/dependency/utils/

Author: gboue
Date: Sun Jun 18 18:00:24 2017
New Revision: 1799110

URL: http://svn.apache.org/viewvc?rev=1799110&view=rev
Log:
[MDEP-571] JDK9: Issue with list goal fails with java.lang.NoSuchMethodException

Only find public inherited methods through reflection with getMethod instead of getDeclaredMethod.

Added:
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/invoker.properties   (with props)
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/pom.xml   (with props)
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/verify.groovy   (with props)
Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java

Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/invoker.properties?rev=1799110&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/invoker.properties (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/invoker.properties Sun Jun 18 18:00:24 2017
@@ -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.goals = ${project.groupId}:${project.artifactId}:${project.version}:list

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/pom.xml?rev=1799110&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/pom.xml (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/pom.xml Sun Jun 18 18:00:24 2017
@@ -0,0 +1,35 @@
+<?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.dependency</groupId>
+  <artifactId>mdep-571-list-java9</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <description>Test that dependency:list doesn't fail on JRE9</description>
+  <dependencies>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>1.7.6</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/verify.groovy?rev=1799110&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/verify.groovy (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/verify.groovy Sun Jun 18 18:00:24 2017
@@ -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.
+ */
+
+File file = new File( basedir, "build.log" );
+assert file.exists();
+
+String buildLog = file.getText( "UTF-8" );
+assert buildLog.contains( 'org.slf4j:slf4j-api:jar:1.7.6:compile -- module' );
+
+return true;

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/verify.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/mdep-571-list-java9/verify.groovy
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java?rev=1799110&r1=1799109&r2=1799110&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyStatusSets.java Sun Jun 18 18:00:24 2017
@@ -258,27 +258,28 @@ public class DependencyStatusSets
         try
         {
             // Use Java9 code to get moduleName, don't try to do it better with own implementation
-            Class moduleFinderClass = Class.forName( "java.lang.module.ModuleFinder" );
+            Class<?> moduleFinderClass = Class.forName( "java.lang.module.ModuleFinder" );
 
             java.nio.file.Path path = artifactFile.toPath();
             
-            Method ofMethod = moduleFinderClass.getDeclaredMethod( "of", java.nio.file.Path[].class );
+            Method ofMethod = moduleFinderClass.getMethod( "of", java.nio.file.Path[].class );
             Object moduleFinderInstance = ofMethod.invoke( null, new Object[] { new java.nio.file.Path[] { path } } );
             
-            Method findAllMethod = moduleFinderClass.getDeclaredMethod( "findAll" );
+            Method findAllMethod = moduleFinderClass.getMethod( "findAll" );
+            @SuppressWarnings( "unchecked" )
             Set<Object> moduleReferences = (Set<Object>) findAllMethod.invoke( moduleFinderInstance );
             
             Object moduleReference = moduleReferences.iterator().next();
-            Method descriptorMethod = moduleReference.getClass().getDeclaredMethod( "descriptor" );
+            Method descriptorMethod = moduleReference.getClass().getMethod( "descriptor" );
             Object moduleDescriptorInstance = descriptorMethod.invoke( moduleReference );
             
-            Method nameMethod = moduleDescriptorInstance.getClass().getDeclaredMethod( "name" );
+            Method nameMethod = moduleDescriptorInstance.getClass().getMethod( "name" );
             String name = (String) nameMethod.invoke( moduleDescriptorInstance );
             
             moduleDescriptor = new ModuleDescriptor();
             moduleDescriptor.name = name;
             
-            Method isAutomaticMethod = moduleDescriptorInstance.getClass().getDeclaredMethod( "isAutomatic" );
+            Method isAutomaticMethod = moduleDescriptorInstance.getClass().getMethod( "isAutomatic" );
             moduleDescriptor.automatic = (Boolean) isAutomaticMethod.invoke( moduleDescriptorInstance );
         }
         catch ( ClassNotFoundException e )