Author: gboue
Date: Sat Nov 12 19:43:02 2016
New Revision: 1769402

URL: http://svn.apache.org/viewvc?rev=1769402&view=rev
Log:
[MPH-53] mvn help:describe returns the version that is specified in metadata 
instead of the one in the parent pom

Set the POM to use in the plugin version requuest, so that plugin versions 
declared in it are correctly used.

Added:
    
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/
    
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/invoker.properties
   (with props)
    
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/pom.xml
   (with props)
    
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/test.properties
   (with props)
    
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/verify.groovy
   (with props)
Modified:
    
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
    
maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java

Added: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/invoker.properties?rev=1769402&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/invoker.properties
 Sat Nov 12 19:43:02 2016
@@ -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.goals = 
${project.groupId}:${project.artifactId}:${project.version}:describe

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/pom.xml?rev=1769402&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/pom.xml
 Sat Nov 12 19:43:02 2016
@@ -0,0 +1,43 @@
+<?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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.help</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <url>https://issues.apache.org/jira/browse/MPH-53</url>
+  <description>
+    Tests that the describe goal correctly resolves the version of the plugin 
to describe from the POM, if defined.
+  </description>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.4.3</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/test.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/test.properties?rev=1769402&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/test.properties
 (added)
+++ 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/test.properties
 Sat Nov 12 19:43:02 2016
@@ -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.
+
+plugin = surefire
+output = result.txt

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/verify.groovy
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/verify.groovy?rev=1769402&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/verify.groovy
 (added)
+++ 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/verify.groovy
 Sat Nov 12 19:43:02 2016
@@ -0,0 +1,30 @@
+/*
+ * 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 result = new File(basedir, 'result.txt').text;
+def ls = System.getProperty( "line.separator" );
+
+assert result.contains(
+  "Group Id: org.apache.maven.plugins" + ls + 
+  "Artifact Id: maven-surefire-plugin" + ls + 
+  "Version: 2.4.3" + ls +
+  "Goal Prefix: surefire"
+)
+
+return true;

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/verify.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-help-plugin/src/it/describe-plugin-in-plugin-management/verify.groovy
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java?rev=1769402&r1=1769401&r2=1769402&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-help-plugin/src/main/java/org/apache/maven/plugins/help/DescribeMojo.java
 Sat Nov 12 19:43:02 2016
@@ -372,8 +372,9 @@ public class DescribeMojo
         {
             try
             {
-                PluginVersionResult versionResult =
-                    pluginVersionResolver.resolve( new 
DefaultPluginVersionRequest( forLookup, session ) );
+                DefaultPluginVersionRequest versionRequest = new 
DefaultPluginVersionRequest( forLookup, session );
+                versionRequest.setPom( project.getModel() );
+                PluginVersionResult versionResult = 
pluginVersionResolver.resolve( versionRequest );
                 forLookup.setVersion( versionResult.getVersion() );
             }
             catch ( PluginVersionResolutionException e )

Modified: 
maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java?rev=1769402&r1=1769401&r2=1769402&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
 (original)
+++ 
maven/plugins/trunk/maven-help-plugin/src/test/java/org/apache/maven/plugins/help/DescribeMojoTest.java
 Sat Nov 12 19:43:02 2016
@@ -36,6 +36,7 @@ import org.apache.maven.plugin.version.P
 import org.apache.maven.plugin.version.PluginVersionResolver;
 import org.apache.maven.plugin.version.PluginVersionResult;
 import org.apache.maven.plugins.help.DescribeMojo.PluginInfo;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.exec.MavenPluginManagerHelper;
 import org.mockito.ArgumentCaptor;
 
@@ -263,6 +264,7 @@ public class DescribeMojoTest
         PrivateAccessor.setField( mojo, "pluginVersionResolver", 
pluginVersionResolver );
         PrivateAccessor.setField( mojo, "pluginManager", pluginManager );
         PrivateAccessor.setField( mojo, "session", session );
+        PrivateAccessor.setField( mojo, "project", new MavenProject() );
         when( mojoDescriptorCreator.findPluginForPrefix( "help", session ) 
).thenReturn( plugin );
         when( pluginVersionResolver.resolve( any( PluginVersionRequest.class ) 
) ).thenReturn( versionResult );
         when( versionResult.getVersion() ).thenReturn( "1.0" );


Reply via email to