maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r498044 - in /maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin: DefaultPluginManager.java MavenPluginCollector.java PluginManager.java version/DefaultPluginVersionManager.java version/PluginVersionManager.java
Date Sat, 20 Jan 2007 02:03:28 GMT
Author: jdcasey
Date: Fri Jan 19 18:03:27 2007
New Revision: 498044

URL: http://svn.apache.org/viewvc?view=rev&rev=498044
Log:
Adding methods for backward compat, and deprecating them...and adding a few debug log statements.

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionManager.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?view=diff&rev=498044&r1=498043&r2=498044
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Fri Jan 19 18:03:27 2007
@@ -55,6 +55,7 @@
 import org.apache.maven.project.artifact.MavenMetadataSource;
 import org.apache.maven.project.path.PathTranslator;
 import org.apache.maven.reporting.MavenReport;
+import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
@@ -76,12 +77,9 @@
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
-import java.io.File;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
@@ -101,8 +99,6 @@
 
     private Log mojoLogger;
 
-    private Map resolvedCoreArtifactFiles = new HashMap();
-
     // component requirements
     protected PathTranslator pathTranslator;
 
@@ -149,6 +145,27 @@
                                                  session.getLocalRepository() );
     }
 
+    /**
+     * @deprecated use {@link PluginManager#verifyPlugin(Plugin, MavenProject, Settings)}
+     */
+    public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
+                                          ArtifactRepository localRepository )
+        throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
+        InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException,
PluginNotFoundException,
+        PluginVersionNotFoundException
+    {
+        // TODO: this should be possibly outside
+        // All version-resolution logic has been moved to DefaultPluginVersionManager.
+        if ( plugin.getVersion() == null )
+        {
+            String version = pluginVersionManager.resolvePluginVersion( plugin.getGroupId(),
plugin.getArtifactId(),
+                                                                        project, settings,
localRepository );
+            plugin.setVersion( version );
+        }
+
+        return verifyVersionedPlugin( plugin, project, localRepository );
+    }
+    
     public PluginDescriptor verifyPlugin( Plugin plugin,
                                           MavenProject project,
                                           MavenSession session )
@@ -175,6 +192,15 @@
         InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException,
PluginNotFoundException
     {
         ArtifactRepository localRepository = session.getLocalRepository();
+        
+        return verifyVersionedPlugin( plugin, project, localRepository );
+    }
+    
+    private PluginDescriptor verifyVersionedPlugin( Plugin plugin, MavenProject project,
+                                                    ArtifactRepository localRepository )
+        throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException,
+        InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException,
PluginNotFoundException
+    {
 
         // TODO: this might result in an artifact "RELEASE" being resolved continuously
         // FIXME: need to find out how a plugin gets marked as 'installed'
@@ -201,7 +227,7 @@
 
             if ( !pluginCollector.isPluginInstalled( plugin ) )
             {
-                addPlugin( plugin, pluginArtifact, project, session );
+                addPlugin( plugin, pluginArtifact, project, localRepository );
             }
 
             project.addPlugin( plugin );
@@ -269,6 +295,31 @@
     protected void addPlugin( Plugin plugin,
                               Artifact pluginArtifact,
                               MavenProject project,
+                              ArtifactRepository localRepository )
+        throws ArtifactNotFoundException, ArtifactResolutionException, PluginManagerException,
InvalidPluginException
+    {
+        // ----------------------------------------------------------------------------
+        // Get the dependencies for the Plugin
+        // ----------------------------------------------------------------------------
+
+        // the only Plugin instance which will have dependencies is the one specified in
the project.
+        // We need to look for a Plugin instance there, in case the instance we're using
didn't come from
+        // the project.
+        Plugin projectPlugin = (Plugin) project.getBuild().getPluginsAsMap().get( plugin.getKey()
);
+
+        if ( projectPlugin == null )
+        {
+            projectPlugin = plugin;
+        }
+
+        Set artifacts = getPluginArtifacts( pluginArtifact, projectPlugin, project, localRepository
);
+        
+        addPlugin( plugin, projectPlugin, pluginArtifact, artifacts );
+    }
+    
+    protected void addPlugin( Plugin plugin,
+                              Artifact pluginArtifact,
+                              MavenProject project,
                               MavenSession session )
         throws ArtifactNotFoundException, ArtifactResolutionException, PluginManagerException,
InvalidPluginException
     {
@@ -286,7 +337,14 @@
             projectPlugin = plugin;
         }
 
-        Set artifacts = getPluginArtifacts( pluginArtifact, projectPlugin, project, session
);
+        Set artifacts = getPluginArtifacts( pluginArtifact, projectPlugin, project, session.getLocalRepository()
);
+        
+        addPlugin( plugin, projectPlugin, pluginArtifact, artifacts );
+    }
+    
+    private void addPlugin( Plugin plugin, Plugin projectPlugin, Artifact pluginArtifact,
Set artifacts )
+        throws ArtifactNotFoundException, ArtifactResolutionException, PluginManagerException,
InvalidPluginException
+    {
 
         // ----------------------------------------------------------------------------
         // Realm creation for a plugin
@@ -320,6 +378,8 @@
         // The PluginCollector will now know about the plugin we are trying to load
         // ----------------------------------------------------------------------------
 
+        getLogger().debug( "Checking for plugin descriptor for: " + plugin.getKey() + " in
collector: " + pluginCollector );
+        
         PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( projectPlugin
);
 
         if ( pluginDescriptor == null )
@@ -339,17 +399,16 @@
 
         pluginDescriptor.setArtifacts( new ArrayList( artifacts ) );
 
-        getLogger().debug( "Realm for plugin: " + plugin.getKey() + ":\n" + componentRealm
);
+        getLogger().info( "Realm for plugin: " + plugin.getKey() + ":\n" + componentRealm
);
 
         pluginDescriptor.setClassRealm( componentRealm );
     }
 
-    private Set getPluginArtifacts( Artifact pluginArtifact,
-                                    Plugin plugin,
-                                    MavenProject project,
-                                    MavenSession session )
+    private Set getPluginArtifacts( Artifact pluginArtifact, Plugin plugin, MavenProject
project,
+                                    ArtifactRepository localRepository )
         throws InvalidPluginException, ArtifactNotFoundException, ArtifactResolutionException
     {
+
         Set projectPluginDependencies;
 
         try
@@ -362,8 +421,6 @@
             throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(),
e );
         }
 
-        ArtifactRepository localRepository = session.getLocalRepository();
-
         ResolutionGroup resolutionGroup;
 
         try
@@ -645,7 +702,14 @@
 
             ClassRealm oldRealm = DefaultPlexusContainer.setLookupRealm( realm );
 
-            plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint(), realm
);
+            if ( realm != null )
+            {
+                plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint(),
realm );
+            }
+            else
+            {
+                plugin = (Mojo) container.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint()
);
+            }
 
             DefaultPlexusContainer.setLookupRealm( oldRealm );
 

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java?view=diff&rev=498044&r1=498043&r2=498044
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginCollector.java
Fri Jan 19 18:03:27 2007
@@ -58,6 +58,8 @@
             {
                 pluginsInProcess.add( key );
 
+                getLogger().debug( this + ": Discovered plugin: " + key );
+                
                 pluginDescriptors.put( key, pluginDescriptor );
 
                 // TODO: throw an (not runtime) exception if there is a prefix overlap -
means doing so elsewhere

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?view=diff&rev=498044&r1=498043&r2=498044
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
Fri Jan 19 18:03:27 2007
@@ -54,6 +54,12 @@
 
     Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject
project );
 
+    PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
+                                   ArtifactRepository localRepository )
+        throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
+        InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException,
PluginNotFoundException,
+        PluginVersionNotFoundException;
+    
     PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, MavenSession session
)
         throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
         InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException,
PluginNotFoundException,

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java?view=diff&rev=498044&r1=498043&r2=498044
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/DefaultPluginVersionManager.java
Fri Jan 19 18:03:27 2007
@@ -87,7 +87,11 @@
                                         MavenSession session )
         throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
     {
-        return resolvePluginVersion( groupId, artifactId, project, session, false );
+        Settings settings = session.getSettings();
+
+        ArtifactRepository localRepository = session.getLocalRepository();
+        
+        return resolvePluginVersion( groupId, artifactId, project, settings, localRepository,
false );
     }
 
     public String resolveReportPluginVersion( String groupId,
@@ -96,19 +100,47 @@
                                               MavenSession session )
         throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
     {
-        return resolvePluginVersion( groupId, artifactId, project, session, true );
+        Settings settings = session.getSettings();
+
+        ArtifactRepository localRepository = session.getLocalRepository();
+        
+        return resolvePluginVersion( groupId, artifactId, project, settings, localRepository,
true );
+    }
+
+    /**
+     * @deprecated
+     */
+    public String resolvePluginVersion( String groupId,
+                                        String artifactId,
+                                        MavenProject project,
+                                        Settings settings,
+                                        ArtifactRepository localRepository )
+        throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
+    {
+        return resolvePluginVersion( groupId, artifactId, project, settings, localRepository,
false );
+    }
+
+    /**
+     * @deprecated
+     */
+    public String resolveReportPluginVersion( String groupId,
+                                              String artifactId,
+                                              MavenProject project,
+                                              Settings settings,
+                                              ArtifactRepository localRepository )
+        throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
+    {
+        return resolvePluginVersion( groupId, artifactId, project, settings, localRepository,
true );
     }
 
     private String resolvePluginVersion( String groupId,
                                          String artifactId,
                                          MavenProject project,
-                                         MavenSession session,
+                                         Settings settings,
+                                         ArtifactRepository localRepository,
                                          boolean resolveAsReportPlugin )
         throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
     {
-        Settings settings = session.getSettings();
-
-        ArtifactRepository localRepository = session.getLocalRepository();
 
         // first pass...if the plugin is specified in the pom, try to retrieve the version
from there.
         String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin
);

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionManager.java?view=diff&rev=498044&r1=498043&r2=498044
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionManager.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/version/PluginVersionManager.java
Fri Jan 19 18:03:27 2007
@@ -16,9 +16,11 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.InvalidPluginException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.settings.Settings;
 
 public interface PluginVersionManager
 {
@@ -27,7 +29,21 @@
     String resolvePluginVersion( String groupId, String artifactId, MavenProject project,
MavenSession session )
         throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
 
+    /**
+     * @deprecated
+     */
+    String resolvePluginVersion( String groupId, String artifactId, MavenProject project,
Settings settings,
+                                 ArtifactRepository localRepository )
+        throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
+
     String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project,
MavenSession session )
+        throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
+
+    /**
+     * @deprecated
+     */
+    String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project,
Settings settings,
+                                       ArtifactRepository localRepository )
         throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
 
 }



Mime
View raw message