You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ca...@apache.org on 2006/05/28 21:50:38 UTC
svn commit: r409984 -
/maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.java
Author: carlos
Date: Sun May 28 12:50:38 2006
New Revision: 409984
URL: http://svn.apache.org/viewvc?rev=409984&view=rev
Log:
[MSITE-25] site deploy ignores server configuration in settings.xml
Submitted by: Petter L. H. Eide
Modified:
maven/plugins/trunk/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteDeployMojo.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=409984&r1=409983&r2=409984&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 Sun May 28 12:50:38 2006
@@ -16,6 +16,11 @@
* limitations under the License.
*/
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.artifact.manager.WagonConfigurationException;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Site;
@@ -36,8 +41,16 @@
import org.apache.maven.wagon.observers.Debug;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository;
-
-import java.io.File;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+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.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
/**
* Deploys website using scp/file protocol.
@@ -52,7 +65,7 @@
* @goal deploy
*/
public class SiteDeployMojo
- extends AbstractMojo
+ extends AbstractMojo implements Contextualizable
{
/**
* Directory containing the generated project sites and report distributions.
@@ -83,6 +96,11 @@
*/
private Settings settings;
+ private PlexusContainer container;
+
+ /** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */
+ private Map serverConfigurationMap = new HashMap();
+
public void execute()
throws MojoExecutionException
{
@@ -120,14 +138,21 @@
// TODO: work on moving this into the deployer like the other deploy methods
Wagon wagon;
+
try
{
+ // TODO use WagonManager#getWagon(Repository) when available
wagon = wagonManager.getWagon( repository.getProtocol() );
+ configureWagon( wagon, repository.getId() );
}
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() )
{
@@ -224,4 +249,57 @@
return proxyInfo;
}
+
+ /**
+ * Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
+ *
+ * @todo remove when {@link WagonManager#getWagon(Repository) is available}
+ * @param wagon
+ * @param repositoryId
+ * @throws WagonConfigurationException
+ */
+ private void configureWagon( Wagon wagon, String repositoryId )
+ throws WagonConfigurationException
+ {
+ if ( serverConfigurationMap.containsKey( repositoryId ) )
+ {
+ ComponentConfigurator componentConfigurator = null;
+ try
+ {
+ 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 )
+ {
+ try
+ {
+ container.release( componentConfigurator );
+ }
+ catch ( ComponentLifecycleException e )
+ {
+ getLog().error( "Problem releasing configurator - ignoring: " + e.getMessage() );
+ }
+ }
+
+ }
+ }
+ }
+
+ public void contextualize( Context context )
+ throws ContextException
+ {
+ container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+ }
+
}