Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 71433 invoked from network); 19 Mar 2011 22:11:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Mar 2011 22:11:42 -0000 Received: (qmail 32489 invoked by uid 500); 19 Mar 2011 22:11:42 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 32417 invoked by uid 500); 19 Mar 2011 22:11:42 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 32410 invoked by uid 99); 19 Mar 2011 22:11:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Mar 2011 22:11:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Mar 2011 22:11:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 733A923888C2; Sat, 19 Mar 2011 22:11:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Sat, 19 Mar 2011 22:11:18 -0000 To: commits@maven.apache.org From: hboutemy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110319221118.733A923888C2@eris.apache.org> 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. maven-settings ${mavenVersion} + + org.apache.maven + maven-settings-builder + ${mavenVersion} + 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 null 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