maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r819744 - in /maven/plugins/branches/maven-site-plugin-3.x/src: it/no-version/pom.xml main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java
Date Mon, 28 Sep 2009 21:51:22 GMT
Author: olamy
Date: Mon Sep 28 21:51:21 2009
New Revision: 819744

URL: http://svn.apache.org/viewvc?rev=819744&view=rev
Log:
if empty try to resolve/find plugin  version from the pom :
- first from build.plugins.
- second from build.pluginManagement.plugins.
- third with the current repositories (can resolve a SNAPSHOT version)

Modified:
    maven/plugins/branches/maven-site-plugin-3.x/src/it/no-version/pom.xml
    maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java

Modified: maven/plugins/branches/maven-site-plugin-3.x/src/it/no-version/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/it/no-version/pom.xml?rev=819744&r1=819743&r2=819744&view=diff
==============================================================================
--- maven/plugins/branches/maven-site-plugin-3.x/src/it/no-version/pom.xml (original)
+++ maven/plugins/branches/maven-site-plugin-3.x/src/it/no-version/pom.xml Mon Sep 28 21:51:21
2009
@@ -22,6 +22,11 @@
         <artifactId>maven-site-plugin</artifactId>
         <version>@project.version@</version>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-report-plugin</artifactId>
+        <version>2.4.3</version>
+      </plugin>      
     </plugins>
   </build>  
   <reporting>

Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java?rev=819744&r1=819743&r2=819744&view=diff
==============================================================================
--- maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java
(original)
+++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/DefaultMavenReportExecutor.java
Mon Sep 28 21:51:21 2009
@@ -43,11 +43,13 @@
 import org.apache.maven.plugin.version.PluginVersionResolutionException;
 import org.apache.maven.plugin.version.PluginVersionResolver;
 import org.apache.maven.plugin.version.PluginVersionResult;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.MavenReport;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomUtils;
 
@@ -109,7 +111,7 @@
                 Plugin plugin = new Plugin();
                 plugin.setGroupId( reportPlugin.getGroupId() );
                 plugin.setArtifactId( reportPlugin.getArtifactId() );
-                plugin.setVersion( getPluginVersion (reportPlugin, repositoryRequest ) );
+                plugin.setVersion( getPluginVersion (reportPlugin, repositoryRequest, mavenReportExecutorRequest.getProject()
) );
 
                 if (logger.isInfoEnabled())
                 {
@@ -342,7 +344,7 @@
         return logger;
     }
     
-    protected String getPluginVersion( ReportPlugin reportPlugin, RepositoryRequest repositoryRequest
)
+    protected String getPluginVersion( ReportPlugin reportPlugin, RepositoryRequest repositoryRequest,
MavenProject project )
         throws PluginVersionResolutionException
     {
         if ( getLog().isDebugEnabled() )
@@ -353,6 +355,38 @@
         {
             return reportPlugin.getVersion();
         }
+        
+        // search in the build section
+        if ( project.getBuild() != null )
+        {
+            Plugin plugin = find( reportPlugin.getGroupId(), reportPlugin.getArtifactId(),
project.getBuild().getPlugins() );
+            if (plugin != null && plugin.getVersion() != null)
+            {
+                if (getLog().isDebugEnabled())
+                {
+                    logger.debug( "resolve version from the build.plugins section " + plugin.getVersion()
);
+                }
+                return plugin.getVersion();
+            }
+        }
+        
+        // search in pluginMngt section
+        if ( project.getBuild() != null && project.getBuild().getPluginManagement()
!= null )
+        {
+            Plugin plugin =
+                find( reportPlugin.getGroupId(), reportPlugin.getArtifactId(),
+                      project.getBuild().getPluginManagement().getPlugins() );
+            if ( plugin != null && plugin.getVersion() != null )
+            {
+                if ( getLog().isDebugEnabled() )
+                {
+                    logger.debug( "resolve version from the build.pluginManagement.plugins
section " + plugin.getVersion() );
+                }
+                return plugin.getVersion();
+            }
+        }        
+        
+        
         logger.warn( "report plugin " + reportPlugin.getGroupId() + ":" + reportPlugin.getArtifactId()
             + " has an empty version" );
         logger.warn( "" );
@@ -375,4 +409,21 @@
         }
         return result.getVersion();
     }
+    
+    private Plugin find( String groupId, String artifactId, List<Plugin> plugins )
+    {
+        if ( plugins == null )
+        {
+            return null;
+        }
+        for ( Plugin plugin : plugins )
+        {
+            if ( StringUtils.equals( plugin.getArtifactId(), artifactId )
+                && StringUtils.equals( plugin.getGroupId(), groupId ) )
+            {
+                return plugin;
+            }
+        }
+        return null;
+    }
 }



Mime
View raw message