You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2011/03/19 23:11:18 UTC

svn commit: r1083311 - in /maven/plugins/branches/MSITE-560: ./ src/main/java/org/apache/maven/plugins/site/ src/test/java/org/apache/maven/plugins/site/

Author: hboutemy
Date: Sat Mar 19 22:11:18 2011
New Revision: 1083311

URL: http://svn.apache.org/viewvc?rev=1083311&view=rev
Log:
fixed deploy goals under Maven 2.2

Modified:
    maven/plugins/branches/MSITE-560/pom.xml
    maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
    maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractSiteMojo.java
    maven/plugins/branches/MSITE-560/src/test/java/org/apache/maven/plugins/site/AbstractSiteDeployWebDavTest.java

Modified: maven/plugins/branches/MSITE-560/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MSITE-560/pom.xml?rev=1083311&r1=1083310&r2=1083311&view=diff
==============================================================================
--- maven/plugins/branches/MSITE-560/pom.xml (original)
+++ maven/plugins/branches/MSITE-560/pom.xml Sat Mar 19 22:11:18 2011
@@ -234,6 +234,11 @@ under the License.
       <artifactId>maven-settings</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-settings-builder</artifactId>
+      <version>${mavenVersion}</version>
+    </dependency>
     
     <!-- Doxia -->
 

Modified: maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java?rev=1083311&r1=1083310&r2=1083311&view=diff
==============================================================================
--- maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java (original)
+++ maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java Sat Mar 19 22:11:18 2011
@@ -54,6 +54,7 @@ import org.apache.maven.wagon.observers.
 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.component.configurator.ComponentConfigurationException;
 import org.codehaus.plexus.component.configurator.ComponentConfigurator;
@@ -61,6 +62,9 @@ import org.codehaus.plexus.component.rep
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
@@ -73,7 +77,7 @@ import org.codehaus.plexus.util.xml.Xpp3
  * @since 2.3
  */
 public abstract class AbstractDeployMojo
-    extends AbstractSiteMojo
+    extends AbstractSiteMojo implements Contextualizable
 {
     /**
      * Directory containing the generated project sites and report distributions.
@@ -132,17 +136,6 @@ public abstract class AbstractDeployMojo
      */
     protected MavenSession mavenSession;
 
-    /**
-     * @since 3.0-beta-2
-     * @component
-     * @readonly
-     */
-    private SettingsDecrypter settingsDecrypter;
-
-    /**
-     * @component
-     * @readonly
-     */
     private PlexusContainer container;
 
     /** {@inheritDoc} */
@@ -238,7 +231,24 @@ public abstract class AbstractDeployMojo
 
         try
         {
-            final ProxyInfo proxyInfo = getProxy( repository, getLog(), mavenSession, settingsDecrypter );
+            final ProxyInfo proxyInfo;
+            if ( getMavenVersion().startsWith( "2." ) )
+            {
+                proxyInfo = getProxyInfo( repository, wagonManager );
+            }
+            else
+            {
+                try
+                {
+                    SettingsDecrypter settingsDecrypter = container.lookup( SettingsDecrypter.class );
+
+                    proxyInfo = getProxy( repository, getLog(), mavenSession, settingsDecrypter );
+                }
+                catch ( ComponentLookupException cle )
+                {
+                    throw new MojoExecutionException( "Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle );
+                }
+            }
 
             push( directory, repository, wagonManager, wagon, proxyInfo,
                 siteTool.getAvailableLocales( locales ), getDeployModuleDirectory(), getLog() );
@@ -324,7 +334,8 @@ public abstract class AbstractDeployMojo
         throws MojoExecutionException
     {
         AuthenticationInfo authenticationInfo = manager.getAuthenticationInfo( repository.getId() );
-        log.debug( "authenticationInfo with id '" + repository.getId() + "': " + authenticationInfo.getUserName() );
+        log.debug( "authenticationInfo with id '" + repository.getId() + "': "
+                   + ( ( authenticationInfo == null ) ? "-" : authenticationInfo.getUserName() ) );
 
         try
         {
@@ -427,7 +438,7 @@ public abstract class AbstractDeployMojo
      * @param wagonManager the WagonManager used to connect to the Repository.
      * @return a ProxyInfo object instantiated or <code>null</code> if no matching proxy is found
      */
-    public static ProxyInfo getProxyInfo( Repository repository, WagonManager wagonManager )
+    public ProxyInfo getProxyInfo( Repository repository, WagonManager wagonManager )
     {
         ProxyInfo proxyInfo = wagonManager.getProxy( repository.getProtocol() );
 
@@ -484,7 +495,7 @@ public abstract class AbstractDeployMojo
      * @param settingsDecrypter
      * @return
      */
-    private static ProxyInfo getProxy( Repository repository, Log log, MavenSession mavenSession, SettingsDecrypter settingsDecrypter )
+    private ProxyInfo getProxy( Repository repository, Log log, MavenSession mavenSession, SettingsDecrypter settingsDecrypter )
     {
         String protocol = repository.getProtocol();
         String url = repository.getUrl();
@@ -628,6 +639,13 @@ public abstract class AbstractDeployMojo
         }
     }
 
+    /** {@inheritDoc} */
+    public void contextualize( Context context )
+        throws ContextException
+    {
+        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+    }
+
     /**
      * Find the top level parent in the reactor, i.e. the execution root.
      *

Modified: maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractSiteMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractSiteMojo.java?rev=1083311&r1=1083310&r2=1083311&view=diff
==============================================================================
--- maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractSiteMojo.java (original)
+++ maven/plugins/branches/MSITE-560/src/main/java/org/apache/maven/plugins/site/AbstractSiteMojo.java Sat Mar 19 22:11:18 2011
@@ -20,8 +20,11 @@ package org.apache.maven.plugins.site;
  */
 
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
 
 import java.util.List;
+import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.doxia.tools.SiteTool;
@@ -29,6 +32,7 @@ import org.apache.maven.plugin.AbstractM
 import org.apache.maven.project.MavenProject;
 
 import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 
 /**
@@ -127,4 +131,29 @@ public abstract class AbstractSiteMojo
     {
         return ( outputEncoding == null ) ? ReaderFactory.UTF_8 : outputEncoding;
     }
+
+    protected String getMavenVersion()
+    {
+        // This relies on the fact that MavenProject is the in core classloader
+        // and that the core classloader is for the maven-core artifact
+        // and that should have a pom.properties file
+        // if this ever changes, we will have to revisit this code.
+        final Properties properties = new Properties();
+        final InputStream in =
+            MavenProject.class.getClassLoader().getResourceAsStream( "META-INF/maven/org.apache.maven/maven-core/pom.properties" );
+        try
+        {
+            properties.load( in );
+        }
+        catch ( IOException ioe )
+        {
+            return "";
+        }
+        finally
+        {
+            IOUtil.close( in );
+        }
+
+        return properties.getProperty( "version" ).trim();
+    }
 }

Modified: maven/plugins/branches/MSITE-560/src/test/java/org/apache/maven/plugins/site/AbstractSiteDeployWebDavTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MSITE-560/src/test/java/org/apache/maven/plugins/site/AbstractSiteDeployWebDavTest.java?rev=1083311&r1=1083310&r2=1083311&view=diff
==============================================================================
--- maven/plugins/branches/MSITE-560/src/test/java/org/apache/maven/plugins/site/AbstractSiteDeployWebDavTest.java (original)
+++ maven/plugins/branches/MSITE-560/src/test/java/org/apache/maven/plugins/site/AbstractSiteDeployWebDavTest.java Sat Mar 19 22:11:18 2011
@@ -128,9 +128,6 @@ public abstract class AbstractSiteDeploy
             
             setVariableValueToObject( mojo, "mavenSession", mavenSession );
             
-            SettingsDecrypter settingsDecrypter = getContainer().lookup( SettingsDecrypter.class );
-            setVariableValueToObject( mojo, "settingsDecrypter", settingsDecrypter );
-            
             File inputDirectory = new File("src/test/resources/unit/deploy-dav/target/site");
             
             setVariableValueToObject( mojo, "inputDirectory", inputDirectory );
@@ -198,9 +195,6 @@ public abstract class AbstractSiteDeploy
             
             setVariableValueToObject( mojo, "mavenSession", mavenSession );
             
-            SettingsDecrypter settingsDecrypter = getContainer().lookup( SettingsDecrypter.class );
-            setVariableValueToObject( mojo, "settingsDecrypter", settingsDecrypter );
-            
             File inputDirectory = new File("src/test/resources/unit/deploy-dav/target/site");
             
             // test which mojo we are using