maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r649835 - in /maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site: SiteDeployMojo.java SiteStageDeployMojo.java
Date Sat, 19 Apr 2008 18:01:34 GMT
Author: dennisl
Date: Sat Apr 19 11:01:30 2008
New Revision: 649835

URL: http://svn.apache.org/viewvc?rev=649835&view=rev
Log:
[MSITE-25] mvn site:deploy and site:stage-deploy ignores server configuration in settings.xml
Submitted by: Rahul Akolkar
Reviewed by: Dennis Lundberg

o This patch fixes the site:stage-deploy goal

Modified:
    maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
    maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java

Modified: maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java?rev=649835&r1=649834&r2=649835&view=diff
==============================================================================
--- maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
(original)
+++ maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
Sat Apr 19 11:01:30 2008
@@ -26,6 +26,7 @@
 import org.apache.maven.model.Site;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.settings.Server;
 import org.apache.maven.settings.Settings;
@@ -104,9 +105,6 @@
 
     private PlexusContainer container;
 
-    /** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration
*/
-    private Map serverConfigurationMap = new HashMap();
-
     public void execute()
         throws MojoExecutionException
     {
@@ -149,7 +147,7 @@
         {
             // @todo Use WagonManager#getWagon(Repository) when available. It's available
in Maven 2.0.5.
             wagon = wagonManager.getWagon( repository.getProtocol() );
-            configureWagon( wagon, repository.getId() );
+            configureWagon( wagon, repository.getId(), settings, container, getLog() );
         }
         catch ( UnsupportedProtocolException e )
         {
@@ -300,52 +298,55 @@
      * @todo Remove when {@link WagonManager#getWagon(Repository) is available}. It's available
in Maven 2.0.5.
      * @param wagon
      * @param repositoryId
+     * @param settings
+     * @param container
+     * @param log
      * @throws WagonConfigurationException
      */
-    private void configureWagon( Wagon wagon, String repositoryId )
+    static void configureWagon( Wagon wagon, String repositoryId, Settings settings, PlexusContainer
container, Log log )
         throws WagonConfigurationException
     {
         // MSITE-25: Make sure that the server settings are inserted
         for ( int i = 0; i < settings.getServers().size(); i++ )
         {
             Server server = (Server) settings.getServers().get( i );
-            if ( server.getConfiguration() != null )
-            {
-                final XmlPlexusConfiguration xmlConf =
-                    new XmlPlexusConfiguration( (Xpp3Dom) server.getConfiguration() );
-                serverConfigurationMap.put( server.getId(), xmlConf );
-            }
-        }
-
-        if ( serverConfigurationMap.containsKey( repositoryId ) )
-        {
-            ComponentConfigurator componentConfigurator = null;
-            try
+            String id = server.getId();
+            if ( id != null && id.equals( repositoryId ) )
             {
-                componentConfigurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE
);
-                componentConfigurator.configureComponent( wagon, (PlexusConfiguration) serverConfigurationMap
-                    .get( repositoryId ), container.getContainerRealm() );
-            }
-            catch ( final ComponentLookupException e )
-            {
-                throw new WagonConfigurationException( repositoryId, "Unable to lookup wagon
configurator. Wagon configuration cannot be applied.", e );
-            }
-            catch ( ComponentConfigurationException e )
-            {
-                throw new WagonConfigurationException( repositoryId, "Unable to apply wagon
configuration.", e );
-            }
-            finally
-            {
-                if ( componentConfigurator != null )
+                if ( server.getConfiguration() != null )
                 {
+                    final PlexusConfiguration plexusConf =
+                        new XmlPlexusConfiguration( (Xpp3Dom) server.getConfiguration() );
+
+                    ComponentConfigurator componentConfigurator = null;
                     try
                     {
-                        container.release( componentConfigurator );
+                        componentConfigurator = (ComponentConfigurator) container.lookup(
ComponentConfigurator.ROLE );
+                        componentConfigurator.configureComponent( wagon, plexusConf, container.getContainerRealm()
);
                     }
-                    catch ( ComponentLifecycleException e )
+                    catch ( final ComponentLookupException e )
                     {
-                        getLog().error( "Problem releasing configurator - ignoring: " + e.getMessage()
);
+                        throw new WagonConfigurationException( repositoryId, "Unable to lookup
wagon configurator. Wagon configuration cannot be applied.", e );
                     }
+                    catch ( ComponentConfigurationException e )
+                    {
+                        throw new WagonConfigurationException( repositoryId, "Unable to apply
wagon configuration.", e );
+                    }
+                    finally
+                    {
+                        if ( componentConfigurator != null )
+                        {
+                            try
+                            {
+                                container.release( componentConfigurator );
+                            }
+                            catch ( ComponentLifecycleException e )
+                            {
+                                log.error( "Problem releasing configurator - ignoring: "
+ e.getMessage() );
+                            }
+                        }
+                    }
+
                 }
 
             }

Modified: maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java?rev=649835&r1=649834&r2=649835&view=diff
==============================================================================
--- maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
(original)
+++ maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
Sat Apr 19 11:01:30 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.maven.artifact.manager.WagonConfigurationException;
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -33,6 +34,11 @@
 import org.apache.maven.wagon.observers.Debug;
 import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.repository.Repository;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 
 import java.io.File;
 
@@ -46,7 +52,7 @@
  * @requiresDependencyResolution test
  */
 public class SiteStageDeployMojo
-    extends SiteStageMojo
+    extends SiteStageMojo implements Contextualizable
 {
     /**
      * Staging site URL to deploy the staging directory.
@@ -70,6 +76,10 @@
      */
     private Settings settings;
 
+    private PlexusContainer container;
+
+    private final String STAGING_SERVER_ID = "stagingSite";
+
     /**
      * @see org.apache.maven.plugin.Mojo#execute()
      */
@@ -92,18 +102,22 @@
     private void deployStagingSite()
         throws MojoExecutionException, MojoFailureException
     {
-        String id = "stagingSite";
-        Repository repository = new Repository( id, stagingSiteURL );
+        Repository repository = new Repository( STAGING_SERVER_ID, stagingSiteURL );
 
         Wagon wagon;
         try
         {
             wagon = wagonManager.getWagon( repository.getProtocol() );
+            SiteDeployMojo.configureWagon( wagon, STAGING_SERVER_ID, settings, container,
getLog() );
         }
         catch ( UnsupportedProtocolException e )
         {
             throw new MojoExecutionException( "Unsupported protocol: '" + repository.getProtocol()
+ "'", e );
         }
+        catch ( WagonConfigurationException e )
+        {
+            throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol()
+ "'", e );
+        }
 
         if ( !wagon.supportsDirectoryCopy() )
         {
@@ -122,11 +136,11 @@
             ProxyInfo proxyInfo = SiteDeployMojo.getProxyInfo( repository, wagonManager );
             if ( proxyInfo != null )
             {
-                wagon.connect( repository, wagonManager.getAuthenticationInfo( id ), proxyInfo
);
+                wagon.connect( repository, wagonManager.getAuthenticationInfo( STAGING_SERVER_ID
), proxyInfo );
             }
             else
             {
-                wagon.connect( repository, wagonManager.getAuthenticationInfo( id ) );
+                wagon.connect( repository, wagonManager.getAuthenticationInfo( STAGING_SERVER_ID
) );
             }
 
             wagon.putDirectory( new File( stagingDirectory, getStructure( project, false
) ), "." );
@@ -163,4 +177,11 @@
             }
         }
     }
+
+    public void contextualize( Context context )
+        throws ContextException
+    {
+        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+    }
+
 }



Mime
View raw message