You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/01/03 15:46:13 UTC
svn commit: r730994 - in
/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit:
DumpAuthMojo.java UsesWagonMojo.java
Author: bentmann
Date: Sat Jan 3 06:46:12 2009
New Revision: 730994
URL: http://svn.apache.org/viewvc?rev=730994&view=rev
Log:
o Added mojo to check auth info in wagon manager
Added:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java (with props)
Modified:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/UsesWagonMojo.java
Added: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java?rev=730994&view=auto
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java (added)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java Sat Jan 3 06:46:12 2009
@@ -0,0 +1,158 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Properties;
+
+/**
+ * Dumps the authentication info registered with the wagon manager for a server to a properties file.
+ *
+ * @goal dump-auth
+ * @phase validate
+ *
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class DumpAuthMojo
+ extends AbstractMojo
+{
+
+ /**
+ * Project base directory used for manual path alignment.
+ *
+ * @parameter default-value="${basedir}"
+ * @readonly
+ */
+ private File basedir;
+
+ /**
+ * The Wagon manager used to retrieve authentication infos.
+ *
+ * @component
+ */
+ private WagonManager wagonManager;
+
+ /**
+ * The path to the properties file used to dump the auth infos.
+ *
+ * @parameter expression="${wagon.propertiesFile}"
+ */
+ private File propertiesFile;
+
+ /**
+ * The set of server identifiers whose auth infos should be dumped.
+ *
+ * @parameter
+ */
+ private String[] serverIds;
+
+ /**
+ * Runs this mojo.
+ *
+ * @throws MojoFailureException If the output file could not be created.
+ */
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ Properties authProperties = new Properties();
+
+ for ( int i = 0; i < serverIds.length; i++ )
+ {
+ String serverId = serverIds[i];
+ getLog().info( "[MAVEN-CORE-IT-LOG] Getting authentication info for server " + serverId );
+
+ AuthenticationInfo authInfo = wagonManager.getAuthenticationInfo( serverId );
+ if ( authInfo != null )
+ {
+ if ( authInfo.getUserName() != null )
+ {
+ authProperties.setProperty( serverId + ".username", authInfo.getUserName() );
+ }
+ if ( authInfo.getPassword() != null )
+ {
+ authProperties.setProperty( serverId + ".password", authInfo.getPassword() );
+ }
+ if ( authInfo.getPrivateKey() != null )
+ {
+ authProperties.setProperty( serverId + ".privateKey", authInfo.getPrivateKey() );
+ }
+ if ( authInfo.getPassphrase() != null )
+ {
+ authProperties.setProperty( serverId + ".passphrase", authInfo.getPassphrase() );
+ }
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] username = " + authInfo.getUserName() );
+ getLog().info( "[MAVEN-CORE-IT-LOG] password = " + authInfo.getPassword() );
+ getLog().info( "[MAVEN-CORE-IT-LOG] private key = " + authInfo.getPrivateKey() );
+ getLog().info( "[MAVEN-CORE-IT-LOG] passphrase = " + authInfo.getPassphrase() );
+ }
+ else
+ {
+ getLog().info( "[MAVEN-CORE-IT-LOG] (no authentication info available)" );
+ }
+ }
+
+ if ( !propertiesFile.isAbsolute() )
+ {
+ propertiesFile = new File( basedir, propertiesFile.getPath() );
+ }
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] Creating output file " + propertiesFile );
+
+ OutputStream out = null;
+ try
+ {
+ propertiesFile.getParentFile().mkdirs();
+ out = new FileOutputStream( propertiesFile );
+ authProperties.store( out, "MAVEN-CORE-IT-LOG" );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Output file could not be created: " + propertiesFile, e );
+ }
+ finally
+ {
+ if ( out != null )
+ {
+ try
+ {
+ out.close();
+ }
+ catch ( IOException e )
+ {
+ // just ignore
+ }
+ }
+ }
+
+ getLog().info( "[MAVEN-CORE-IT-LOG] Created output file " + propertiesFile );
+ }
+
+}
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/DumpAuthMojo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/UsesWagonMojo.java
URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/UsesWagonMojo.java?rev=730994&r1=730993&r2=730994&view=diff
==============================================================================
--- maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/UsesWagonMojo.java (original)
+++ maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-uses-wagon/src/main/java/org/apache/maven/plugin/coreit/UsesWagonMojo.java Sat Jan 3 06:46:12 2009
@@ -42,9 +42,11 @@
{
try
{
+ getLog().info( "[MAVEN-CORE-IT-LOG] Looking up wagon for protocol scp" );
Wagon wagon = wagonManager.getWagon( "scp" );
ScpWagon myWagon = (ScpWagon) wagon;
+ getLog().info( "[MAVEN-CORE-IT-LOG] Looked up and successfully casted scp wagon: " + myWagon );
}
catch( Exception e )
{