You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by lt...@apache.org on 2011/03/06 18:51:47 UTC
svn commit: r1078525 - in /maven/plugins/branches/maven-site-plugin-3.x: ./
src/main/java/org/apache/maven/plugins/site/
src/main/java/org/apache/maven/plugins/site/wagon/repository/
Author: ltheussl
Date: Sun Mar 6 17:51:47 2011
New Revision: 1078525
URL: http://svn.apache.org/viewvc?rev=1078525&view=rev
Log:
merge r1067120 from trunk
Added:
maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
- copied, changed from r1067120, maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java
Modified:
maven/plugins/branches/maven-site-plugin-3.x/ (props changed)
maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java
maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/wagon/repository/Repository.java
Propchange: maven/plugins/branches/maven-site-plugin-3.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Mar 6 17:51:47 2011
@@ -1 +1 @@
-/maven/plugins/trunk/maven-site-plugin:801155,801171,801470,806898-806906,807943-808180,809252,810298,884137,886844,886847,890094,890124,891014,891688,920027,920041,942622,943455,944145,950463,956681,984466,984960,984991,984996,1029307,1033379,1037476,1039137,1039143,1049020,1051139-1051449,1055019,1055033,1055047,1055089,1060289,1063639,1064626,1065576,1065582,1066038,1067103
+/maven/plugins/trunk/maven-site-plugin:801155,801171,801470,806898-806906,807943-808180,809252,810298,884137,886844,886847,890094,890124,891014,891688,920027,920041,942622,943455,944145,950463,956681,984466,984960,984991,984996,1029307,1033379,1037476,1039137,1039143,1049020,1051139-1051449,1055019,1055033,1055047,1055089,1060289,1063639,1064626,1065576,1065582,1066038,1067103,1067120
Copied: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java (from r1067120, maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java)
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java?p2=maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java&p1=maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java&r1=1067120&r2=1078525&rev=1078525&view=diff
==============================================================================
--- maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java (original)
+++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/AbstractDeployMojo.java Sun Mar 6 17:51:47 2011
@@ -20,18 +20,26 @@ package org.apache.maven.plugins.site;
*/
import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.List;
import org.apache.commons.lang.StringUtils;
-import org.apache.maven.artifact.manager.WagonConfigurationException;
import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.repository.legacy.WagonConfigurationException;
+import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
+import org.apache.maven.settings.crypto.SettingsDecrypter;
+import org.apache.maven.settings.crypto.SettingsDecryptionResult;
import org.apache.maven.wagon.CommandExecutionException;
import org.apache.maven.wagon.CommandExecutor;
import org.apache.maven.wagon.ConnectionException;
@@ -40,6 +48,7 @@ import org.apache.maven.wagon.TransferFa
import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.observers.Debug;
import org.apache.maven.wagon.proxy.ProxyInfo;
@@ -118,6 +127,23 @@ public abstract class AbstractDeployMojo
*/
private Settings settings;
+ /**
+ * @parameter expression="${session}"
+ * @required
+ * @readonly
+ * @since 3.0-beta-2
+ */
+ protected MavenSession mavenSession;
+
+
+ /**
+ * @since 3.0-beta-2
+ * @component
+ * @readonly
+ */
+ private SettingsDecrypter settingsDecrypter;
+
+// @Requirement
private PlexusContainer container;
/** {@inheritDoc} */
@@ -186,7 +212,7 @@ public abstract class AbstractDeployMojo
try
{
- configureWagon( wagon, repository.getId(), settings, container, getLog() );
+ configureWagon( wagon, repository, settings, container, getLog() );
}
catch ( WagonConfigurationException e )
{
@@ -195,7 +221,9 @@ public abstract class AbstractDeployMojo
try
{
- push( inputDirectory, repository, wagonManager, wagon );
+ final ProxyInfo proxyInfo = getProxy( repository, getLog(), mavenSession, settingsDecrypter );
+
+ push( inputDirectory, repository, wagonManager, wagon, proxyInfo, getLog() );
if ( chmod )
{
@@ -273,9 +301,12 @@ public abstract class AbstractDeployMojo
}
private static void push( final File inputDirectory, final Repository repository,
- final WagonManager manager, final Wagon wagon )
+ final WagonManager manager, final Wagon wagon, final ProxyInfo proxyInfo,final Log log )
throws MojoExecutionException
{
+ AuthenticationInfo authenticationInfo = manager.getAuthenticationInfo( repository.getId() );
+ log.debug( "authenticationInfo with id '" + repository.getId() + "' : " + authenticationInfo.getUserName() );
+
try
{
Debug debug = new Debug();
@@ -284,17 +315,21 @@ public abstract class AbstractDeployMojo
wagon.addTransferListener( debug );
- ProxyInfo proxyInfo = getProxyInfo( repository, manager );
-
- if ( proxyInfo == null )
+ if ( proxyInfo != null )
+ {
+ log.debug( "connect with proxyInfo" );
+ wagon.connect( repository, authenticationInfo, proxyInfo );
+ }
+ else if ( proxyInfo == null && authenticationInfo != null )
{
- wagon.connect( repository, manager.getAuthenticationInfo( repository.getId() ) );
+ log.debug( "connect with authenticationInfo and without proxyInfo" );
+ wagon.connect( repository, authenticationInfo );
}
else
{
- wagon.connect( repository, manager.getAuthenticationInfo( repository.getId() ), proxyInfo );
+ log.debug( "connect without authenticationInfo and without proxyInfo" );
+ wagon.connect( repository );
}
-
wagon.putDirectory( inputDirectory, "." );
}
catch ( ResourceDoesNotExistException e )
@@ -403,6 +438,84 @@ public abstract class AbstractDeployMojo
return proxyInfo;
}
+
+ private static ProxyInfo getProxy( Repository repository, Log log, MavenSession mavenSession, SettingsDecrypter settingsDecrypter )
+ {
+ String protocol = repository.getProtocol();
+ String url = repository.getUrl();
+
+ log.debug( "repository protocol " + protocol );
+
+ String originalProtocol = protocol;
+ // olamy : hackish here protocol (wagon hint in fact !) is dav
+ // but the real protocol (transport layer) is http(s)
+ // and it's the one use in wagon to find the proxy arghhh
+ // so we will check both
+ if (StringUtils.equalsIgnoreCase( "dav", protocol ) && StringUtils.startsWith( url, "dav:" ))
+ {
+ url = StringUtils.substringAfter( url, "dav:" );
+ if (StringUtils.startsWith( url, "http" ))
+ {
+ try
+ {
+ URL urlSite = new URL( url );
+ protocol = urlSite.getProtocol();
+ log.debug( "find dav protocol so transform to real transport protocol " + protocol );
+ }
+ catch ( MalformedURLException e )
+ {
+ log.warn( "fail to build URL with " + url );
+ }
+
+ }
+ }
+ else
+ {
+ log.debug( "getProxy 'protocol' : " + protocol );
+ }
+ if ( mavenSession != null && protocol != null )
+ {
+ MavenExecutionRequest request = mavenSession.getRequest();
+
+ if ( request != null )
+ {
+ List<Proxy> proxies = request.getProxies();
+
+ if ( proxies != null )
+ {
+ for ( Proxy proxy : proxies )
+ {
+ if ( proxy.isActive()
+ && ( protocol.equalsIgnoreCase( proxy.getProtocol() ) || originalProtocol
+ .equalsIgnoreCase( proxy.getProtocol() ) ) )
+ {
+ SettingsDecryptionResult result = settingsDecrypter
+ .decrypt( new DefaultSettingsDecryptionRequest( proxy ) );
+ proxy = result.getProxy();
+
+ ProxyInfo proxyInfo = new ProxyInfo();
+ proxyInfo.setHost( proxy.getHost() );
+ // so hackish for wagon the protocol is https for site dav : dav:https://dav.codehaus.org/mojo/
+ proxyInfo.setType( protocol );//proxy.getProtocol() );
+ proxyInfo.setPort( proxy.getPort() );
+ proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() );
+ proxyInfo.setUserName( proxy.getUsername() );
+ proxyInfo.setPassword( proxy.getPassword() );
+
+ log.debug( "found proxyInfo "
+ + ( proxyInfo == null ? "null" : "host:port " + proxyInfo.getHost() + ":"
+ + proxyInfo.getPort() + ", " + proxyInfo.getUserName() ) );
+
+ return proxyInfo;
+ }
+ }
+ }
+ }
+ }
+ log.debug( "getProxy 'protocol' : " + protocol + " no ProxyInfo found");
+ return null;
+ }
+
/**
* Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
*
@@ -414,16 +527,19 @@ public abstract class AbstractDeployMojo
* @param log
* @throws WagonConfigurationException
*/
- private static void configureWagon( Wagon wagon, String repositoryId, Settings settings, PlexusContainer container,
- Log log )
+ static void configureWagon( Wagon wagon, Repository repository, Settings settings, PlexusContainer container,
+ Log log )
throws WagonConfigurationException
{
+ log.debug( " configureWagon " );
+
// 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 );
+ log.debug( "configureWagon server " + server.getId() );
String id = server.getId();
- if ( id != null && id.equals( repositoryId ) )
+ if ( id != null && id.equals( repository.getId() ) )
{
if ( server.getConfiguration() != null )
{
@@ -433,18 +549,19 @@ public abstract class AbstractDeployMojo
ComponentConfigurator componentConfigurator = null;
try
{
+ // FIXME role-hint basic ?
componentConfigurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE );
componentConfigurator.configureComponent( wagon, plexusConf, container.getContainerRealm() );
}
catch ( final ComponentLookupException e )
{
- throw new WagonConfigurationException( repositoryId, "Unable to lookup wagon configurator."
+ throw new WagonConfigurationException( repository.getId(), "Unable to lookup wagon configurator."
+ " Wagon configuration cannot be applied.", e );
}
catch ( ComponentConfigurationException e )
{
- throw new WagonConfigurationException( repositoryId, "Unable to apply wagon configuration.",
- e );
+ throw new WagonConfigurationException( repository.getId(), "Unable to apply wagon configuration.",
+ e );
}
finally
{
@@ -460,9 +577,7 @@ public abstract class AbstractDeployMojo
}
}
}
-
}
-
}
}
}
Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java?rev=1078525&r1=1078524&r2=1078525&view=diff
==============================================================================
--- maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java (original)
+++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java Sun Mar 6 17:51:47 2011
@@ -19,51 +19,14 @@ package org.apache.maven.plugins.site;
* under the License.
*/
-import org.apache.commons.lang.StringUtils;
-
-import org.apache.maven.artifact.manager.WagonManager;
-import org.apache.maven.execution.MavenExecutionRequest;
-import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Site;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.repository.legacy.WagonConfigurationException;
-import org.apache.maven.settings.Proxy;
-import org.apache.maven.settings.Server;
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
-import org.apache.maven.settings.crypto.SettingsDecrypter;
-import org.apache.maven.settings.crypto.SettingsDecryptionResult;
-import org.apache.maven.wagon.CommandExecutionException;
-import org.apache.maven.wagon.CommandExecutor;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.UnsupportedProtocolException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-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.PlexusContainer;
import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.codehaus.plexus.component.configurator.ComponentConfigurator;
-import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
-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.util.xml.Xpp3Dom;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
+
/**
* Deploys the generated site using <code>scp</code> or <code>file</code>
@@ -82,447 +45,39 @@ import java.util.List;
* @goal deploy
*/
public class SiteDeployMojo
- extends AbstractSiteMojo
+ extends AbstractDeployMojo
{
- /**
- * Directory containing the generated project sites and report distributions.
- *
- * @parameter alias="outputDirectory" expression="${project.reporting.outputDirectory}"
- * @required
- */
- private File inputDirectory;
-
- /**
- * Whether to run the "chmod" command on the remote site after the deploy.
- * Defaults to "true".
- *
- * @parameter expression="${maven.site.chmod}" default-value="true"
- * @since 2.1
- */
- private boolean chmod;
-
- /**
- * The mode used by the "chmod" command. Only used if chmod = true.
- * Defaults to "g+w,a+rX".
- *
- * @parameter expression="${maven.site.chmod.mode}" default-value="g+w,a+rX"
- * @since 2.1
- */
- private String chmodMode;
-
- /**
- * The options used by the "chmod" command. Only used if chmod = true.
- * Defaults to "-Rf".
- *
- * @parameter expression="${maven.site.chmod.options}" default-value="-Rf"
- * @since 2.1
- */
- private String chmodOptions;
-
- /**
- * @component
- */
- private WagonManager wagonManager;
-
- /**
- * The current user system settings for use in Maven.
- *
- * @parameter expression="${settings}"
- * @required
- * @readonly
- */
- private Settings settings;
-
- /**
- * @parameter expression="${session}"
- * @required
- * @readonly
- * @since 3.0-beta-2
- */
- protected MavenSession mavenSession;
-
-
- /**
- * @since 3.0-beta-2
- * @component
- * @readonly
- */
- private SettingsDecrypter settingsDecrypter;
+ private Site site;
@Requirement
private PlexusContainer container;
- // FIXME too much duplicate code with SiteStageDeployMojo
- /** {@inheritDoc} */
- public void execute()
+ @Override
+ public String getDeployRepositoryID()
throws MojoExecutionException
{
- final Site site = getSite( project );
-
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "The site will be deployed to '" + site.getUrl() + "'");
- getLog().debug( "Using credentials from repository '" + site.getId() + "'" );
- }
-
- deployTo( site.getId(), site.getUrl() );
- }
-
- /**
- * Use wagon to deploy the generated site to a given repository.
- *
- * @param id the id that is used to look up credentials for the deploy. Not null.
- * @param url a valid scm url to deploy to. Not null.
- *
- * @throws MojoExecutionException if the deploy fails.
- *
- * @since 2.3
- */
- protected void deployTo( final String id, final String url )
- throws MojoExecutionException
- {
- if ( !inputDirectory.exists() )
- {
- throw new MojoExecutionException( "The site does not exist, please run site:site first" );
- }
-
- Repository repository = new Repository( id, url );
- // TODO: work on moving this into the deployer like the other deploy methods
-
- Wagon wagon;
-
- String protocol = repository.getProtocol();
-
- getLog().debug( "repository protocol " + protocol );
-
- ProxyInfo proxyInfo = getProxy( protocol, url, getLog(), mavenSession, settingsDecrypter );
- getLog().debug( "found proxyInfo "
- + ( proxyInfo == null ? "null" : "host:port " + proxyInfo.getHost() + ":"
- + proxyInfo.getPort() + ", " + proxyInfo.getUserName() ) );
- AuthenticationInfo authenticationInfo = wagonManager.getAuthenticationInfo( id );
- getLog().debug( "authenticationInfo with id '" + id + "' : " + authenticationInfo.getUserName() );
-
- try
- {
- wagon = wagonManager.getWagon( repository );
- configureWagon( wagon, repository, 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() )
- {
- throw new MojoExecutionException(
- "Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying" );
- }
-
- try
- {
- Debug debug = new Debug();
-
- wagon.addSessionListener( debug );
-
- wagon.addTransferListener( debug );
-
- if ( proxyInfo != null )
- {
- getLog().debug( "connect with proxyInfo" );
- wagon.connect( repository, authenticationInfo, proxyInfo );
- }
- else if ( proxyInfo == null && authenticationInfo != null )
- {
- getLog().debug( "connect with authenticationInfo and without proxyInfo" );
- wagon.connect( repository, authenticationInfo );
- }
- else
- {
- getLog().debug( "connect without authenticationInfo and without proxyInfo" );
- wagon.connect( repository );
- }
- wagon.putDirectory( inputDirectory, "." );
-
- if ( chmod && wagon instanceof CommandExecutor )
- {
- CommandExecutor exec = (CommandExecutor) wagon;
- exec.executeCommand( "chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir() );
- }
- }
- catch ( ResourceDoesNotExistException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( TransferFailedException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( AuthorizationException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( ConnectionException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( AuthenticationException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( CommandExecutionException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- finally
- {
- try
- {
- wagon.disconnect();
- }
- catch ( ConnectionException e )
- {
- getLog().error( "Error disconnecting wagon - ignored", e );
- }
- }
- }
-
- /**
- * <p>
- * Get the <code>ProxyInfo</code> of the proxy associated with the <code>host</code>
- * and the <code>protocol</code> of the given <code>repository</code>.
- * </p>
- * <p>
- * Extract from <a href="http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html">
- * J2SE Doc : Networking Properties - nonProxyHosts</a> : "The value can be a list of hosts,
- * each separated by a |, and in addition a wildcard character (*) can be used for matching"
- * </p>
- * <p>
- * Defensively support for comma (",") and semi colon (";") in addition to pipe ("|") as separator.
- * </p>
- *
- * @param repository the Repository to extract the ProxyInfo from.
- * @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, Log log )
- {
-
- ProxyInfo proxyInfo = wagonManager.getProxy( repository.getProtocol() );
-
-
- if ( proxyInfo == null )
- {
- log.debug( "no ProxyInfo for Repository 'id' " + repository.getId() + " 'protocol' " + repository.getProtocol() );
- return null;
- }
-
- String host = repository.getHost();
- String nonProxyHostsAsString = proxyInfo.getNonProxyHosts();
- String[] nonProxyHosts = StringUtils.split( nonProxyHostsAsString, ",;|" );
- for ( int i = 0; i < nonProxyHosts.length; i++ )
- {
- String nonProxyHost = nonProxyHosts[i];
- if ( StringUtils.contains( nonProxyHost, "*" ) )
- {
- // Handle wildcard at the end, beginning or middle of the nonProxyHost
- String nonProxyHostPrefix = StringUtils.substringBefore( nonProxyHost, "*" );
- String nonProxyHostSuffix = StringUtils.substringAfter( nonProxyHost, "*" );
- // prefix*
- if ( StringUtils.isNotEmpty( nonProxyHostPrefix ) && host.startsWith( nonProxyHostPrefix )
- && StringUtils.isEmpty( nonProxyHostSuffix ) )
- {
- return null;
- }
- // *suffix
- if ( StringUtils.isEmpty( nonProxyHostPrefix )
- && StringUtils.isNotEmpty( nonProxyHostSuffix ) && host.endsWith( nonProxyHostSuffix ) )
- {
- return null;
- }
- // prefix*suffix
- if ( StringUtils.isNotEmpty( nonProxyHostPrefix ) && host.startsWith( nonProxyHostPrefix )
- && StringUtils.isNotEmpty( nonProxyHostSuffix ) && host.endsWith( nonProxyHostSuffix ) )
- {
- return null;
- }
- }
- else if ( host.equals( nonProxyHost ) )
- {
- return null;
- }
- }
- return proxyInfo;
-
- }
-
- public static ProxyInfo getProxy( String protocol, String url, Log log, MavenSession mavenSession, SettingsDecrypter settingsDecrypter )
- {
- String originalProtocol = protocol;
- // olamy : hackish here protocol (wagon hint in fact !) is dav
- // but the real protocol (transport layer) is http(s)
- // and it's the one use in wagon to find the proxy arghhh
- // so we will check both
- if (StringUtils.equalsIgnoreCase( "dav", protocol ) && StringUtils.startsWith( url, "dav:" ))
- {
- url = StringUtils.substringAfter( url, "dav:" );
- if (StringUtils.startsWith( url, "http" ))
- {
- try
- {
- URL urlSite = new URL( url );
- protocol = urlSite.getProtocol();
- log.debug( "find dav protocol so transform to real transport protocol " + protocol );
- }
- catch ( MalformedURLException e )
- {
- log.warn( "fail to build URL with " + url );
- }
-
- }
- }
- else
+ if ( site == null )
{
- log.debug( "getProxy 'protocol' : " + protocol );
+ site = getSite( project );
}
- if ( mavenSession != null && protocol != null )
- {
- MavenExecutionRequest request = mavenSession.getRequest();
- if ( request != null )
- {
- List<Proxy> proxies = request.getProxies();
-
- if ( proxies != null )
- {
- for ( Proxy proxy : proxies )
- {
- if ( proxy.isActive()
- && ( protocol.equalsIgnoreCase( proxy.getProtocol() ) || originalProtocol
- .equalsIgnoreCase( proxy.getProtocol() ) ) )
- {
- SettingsDecryptionResult result = settingsDecrypter
- .decrypt( new DefaultSettingsDecryptionRequest( proxy ) );
- proxy = result.getProxy();
-
- ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setHost( proxy.getHost() );
- // so hackish for wagon the protocol is https for site dav : dav:https://dav.codehaus.org/mojo/
- proxyInfo.setType( protocol );//proxy.getProtocol() );
- proxyInfo.setPort( proxy.getPort() );
- proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() );
- proxyInfo.setUserName( proxy.getUsername() );
- proxyInfo.setPassword( proxy.getPassword() );
-
- return proxyInfo;
- }
- }
- }
- }
- }
- log.debug( "getProxy 'protocol' : " + protocol + " no ProxyInfo found");
- return null;
- }
-
-
- /**
- * Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
- *
- * @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
- */
- static void configureWagon( Wagon wagon, Repository repository, Settings settings, PlexusContainer container,
- Log log )
- throws WagonConfigurationException
- {
- log.debug( " configureWagon " );
-
- // 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 );
- log.debug( "configureWagon server " + server.getId() );
- String id = server.getId();
- if ( id != null && id.equals( repository.getId() ) )
- {
- if ( server.getConfiguration() != null )
- {
- final PlexusConfiguration plexusConf =
- new XmlPlexusConfiguration( (Xpp3Dom) server.getConfiguration() );
-
- ComponentConfigurator componentConfigurator = null;
- try
- {
- // FIXME role-hint basic ?
- componentConfigurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE );
- componentConfigurator.configureComponent( wagon, plexusConf, container.getContainerRealm() );
- }
- catch ( final ComponentLookupException e )
- {
- throw new WagonConfigurationException( repository.getId(), "Unable to lookup wagon configurator."
- + " Wagon configuration cannot be applied.", e );
- }
- catch ( ComponentConfigurationException e )
- {
- throw new WagonConfigurationException( repository.getId(), "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() );
- }
- }
- }
- }
- }
- }
+ return site.getId();
}
- /**
- * Find the top level parent in the reactor, i.e. the execution root.
- *
- * @param reactorProjects The projects in the reactor. May be null in which case null is returnned.
- * @return The top level project in the reactor, or <code>null</code> if none can be found
- *
- * @since 2.3
- */
- protected static MavenProject getTopLevelProject( List<MavenProject> reactorProjects )
+ @Override
+ public String getDeployRepositoryURL()
+ throws MojoExecutionException
{
- if ( reactorProjects == null )
- {
- return null;
- }
-
- for ( MavenProject reactorProject : reactorProjects )
+ if ( site == null )
{
- if ( reactorProject.isExecutionRoot() )
- {
- return reactorProject;
- }
+ site = getSite( project );
}
- return null;
+ return site.getUrl();
}
private static Site getSite( final MavenProject project )
- throws MojoExecutionException
+ throws MojoExecutionException
{
final DistributionManagement distributionManagement = project.getDistributionManagement();
Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java?rev=1078525&r1=1078524&r2=1078525&view=diff
==============================================================================
--- maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java (original)
+++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageDeployMojo.java Sun Mar 6 17:51:47 2011
@@ -36,7 +36,7 @@ import java.util.List;
* @requiresDependencyResolution test
*/
public class SiteStageDeployMojo
- extends SiteStageMojo
+ extends AbstractDeployMojo
{
/**
* The staged site will be deployed to this URL.
@@ -66,35 +66,24 @@ public class SiteStageDeployMojo
*/
private String stagingRepositoryId;
- /**
- * {@inheritDoc}
- */
+ private static final String DEFAULT_STAGING_DIRECTORY = "staging";
+
@Override
- public void execute()
+ protected String getDeployRepositoryID()
throws MojoExecutionException
{
- deployStagingSite();
+ return stagingRepositoryId;
}
-
- // FIXME too much duplicate code with SiteDeployMojo
-
- /**
- * Deploy the staging directory using the stagingSiteURL.
- *
- * @throws org.apache.maven.plugin.MojoExecutionException
- * if any
- * @throws org.apache.maven.plugin.MojoFailureException
- * if any
- */
- private void deployStagingSite()
+ @Override
+ protected String getDeployRepositoryURL()
throws MojoExecutionException
{
stagingSiteURL = getStagingSiteURL( project, reactorProjects, stagingSiteURL );
- getLog().info( "Using this URL for stage deploy: " + stagingSiteURL );
+ getLog().info( "Using this URL for stage deploy: " + stagingSiteURL );
- deployTo( stagingRepositoryId, stagingSiteURL );
+ return stagingSiteURL;
}
/**
@@ -105,7 +94,7 @@ public class SiteStageDeployMojo
* @param usersStagingSiteURL The staging site URL as suggested by the user's configuration
* @return the site URL for staging
*/
- protected String getStagingSiteURL( MavenProject currentProject, List<MavenProject> reactorProjects,
+ private String getStagingSiteURL( MavenProject currentProject, List<MavenProject> reactorProjects,
String usersStagingSiteURL )
{
String topLevelURL = null;
Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java?rev=1078525&r1=1078524&r2=1078525&view=diff
==============================================================================
--- maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java (original)
+++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/SiteStageMojo.java Sun Mar 6 17:51:47 2011
@@ -46,7 +46,7 @@ import org.codehaus.plexus.util.StringUt
* @requiresDependencyResolution test
*/
public class SiteStageMojo
- extends SiteDeployMojo
+ extends AbstractDeployMojo
{
protected static final String DEFAULT_STAGING_DIRECTORY = "staging";
@@ -57,13 +57,17 @@ public class SiteStageMojo
*
* @parameter expression="${stagingDirectory}"
*/
- protected File stagingDirectory;
+ private File stagingDirectory;
+
+ @Override
+ protected String getDeployRepositoryID()
+ throws MojoExecutionException
+ {
+ return "stagingLocal";
+ }
- /**
- * @see org.apache.maven.plugin.Mojo#execute()
- */
@Override
- public void execute()
+ protected String getDeployRepositoryURL()
throws MojoExecutionException
{
String structureProject;
@@ -93,10 +97,7 @@ public class SiteStageMojo
outputDirectory.mkdirs();
}
- final String url = "file://" + outputDirectory.getAbsolutePath();
- final String id = "stagingLocal";
-
- deployTo( id, url );
+ return "file://" + outputDirectory.getAbsolutePath();
}
/**
@@ -107,7 +108,7 @@ public class SiteStageMojo
* @param usersStagingDirectory The staging directory as suggested by the user's configuration
* @return the directory for staging
*/
- protected File getStagingDirectory( MavenProject currentProject, List<MavenProject> reactorProjects,
+ private File getStagingDirectory( MavenProject currentProject, List<MavenProject> reactorProjects,
File usersStagingDirectory )
{
// Check if the user has specified a stagingDirectory
@@ -118,23 +119,7 @@ public class SiteStageMojo
}
getLog().debug( "stagingDirectory NOT specified by the user." );
- // Find the top level project in the reactor
- MavenProject topLevelProject = getTopLevelProject( reactorProjects );
-
- // Use the top level project's build directory if there is one, otherwise use this project's build directory
- File buildDirectory;
- if ( topLevelProject == null )
- {
- getLog().debug( "No top level project found in the reactor, using the current project." );
- buildDirectory = new File( currentProject.getBuild().getDirectory() );
- }
- else
- {
- getLog().debug( "Using the top level project found in the reactor." );
- buildDirectory = new File( topLevelProject.getBuild().getDirectory() );
- }
-
- return new File( buildDirectory, DEFAULT_STAGING_DIRECTORY );
+ return new File( getTopLevelBuildDirectory(), DEFAULT_STAGING_DIRECTORY );
}
/**
@@ -146,7 +131,7 @@ public class SiteStageMojo
* @return the structure relative path
* @throws MojoFailureException if any
*/
- protected static String getStructure( MavenProject project, boolean ignoreMissingSiteUrl )
+ private static String getStructure( MavenProject project, boolean ignoreMissingSiteUrl )
throws MojoFailureException
{
if ( project.getDistributionManagement() == null )
Modified: maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/wagon/repository/Repository.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/wagon/repository/Repository.java?rev=1078525&r1=1078524&r2=1078525&view=diff
==============================================================================
--- maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/wagon/repository/Repository.java (original)
+++ maven/plugins/branches/maven-site-plugin-3.x/src/main/java/org/apache/maven/plugins/site/wagon/repository/Repository.java Sun Mar 6 17:51:47 2011
@@ -24,7 +24,6 @@ import org.apache.maven.wagon.WagonConst
import org.apache.maven.wagon.repository.RepositoryPermissions;
import org.codehaus.plexus.util.StringUtils;
-import java.io.Serializable;
import java.util.Properties;
/**
@@ -39,7 +38,7 @@ import java.util.Properties;
* @todo [BP] some things are specific to certain wagons (eg key stuff in authInfo, permissions)
*/
public class Repository
- implements Serializable
+ extends org.apache.maven.wagon.repository.Repository
{
private static final long serialVersionUID = 1312227676322136247L;