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 2007/08/29 18:50:38 UTC

svn commit: r570862 - in /maven/plugins/trunk/maven-stage-plugin/src: main/java/org/apache/maven/plugins/stage/ site/apt/ test/java/org/apache/maven/plugins/stage/

Author: carlos
Date: Wed Aug 29 09:50:37 2007
New Revision: 570862

URL: http://svn.apache.org/viewvc?rev=570862&view=rev
Log:
Fix the problem with authentication not being applied

Modified:
    maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/CopyRepositoryMojo.java
    maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/DefaultRepositoryCopier.java
    maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/RepositoryCopier.java
    maven/plugins/trunk/maven-stage-plugin/src/site/apt/index.apt
    maven/plugins/trunk/maven-stage-plugin/src/site/apt/usage.apt
    maven/plugins/trunk/maven-stage-plugin/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java

Modified: maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/CopyRepositoryMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/CopyRepositoryMojo.java?rev=570862&r1=570861&r2=570862&view=diff
==============================================================================
--- maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/CopyRepositoryMojo.java (original)
+++ maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/CopyRepositoryMojo.java Wed Aug 29 09:50:37 2007
@@ -52,20 +52,18 @@
     private String target;
 
     /**
-     * The id of the target repository.
+     * The id of the source repository, required if you need the configuration from the user settings.
      * 
-     * @parameter expression="${repositoryId}" default-value="target"
+     * @parameter expression="${sourceRepositoryId}" default-value="source"
      */
-    private String repositoryId;
+    private String sourceRepositoryId;
 
     /**
-     * The plugin doesn't currently read username/password from settings.xml.
-     * If your local username is different than your Apache username, you can
-     * specify your Apache username with this parameter.
-     *
-     * @parameter expression="${stage.username}"
+     * The id of the target repository, required if you need the configuration from the user settings.
+     * 
+     * @parameter expression="${targetRepositoryId}" default-value="target"
      */
-    private String username;
+    private String targetRepositoryId;
 
     /**
      * The version of the artifact that is to be copied.
@@ -91,16 +89,9 @@
     {
         try
         {
-            Repository targetRepository = new Repository( repositoryId, target );
-            getLog().debug( "username: " + username );
-            if ( StringUtils.isEmpty( username ) )
-            {
-                copier.copy( source, targetRepository, version );
-            }
-            else
-            {
-                copier.copy( source, targetRepository, version, username );
-            }
+            Repository sourceRepository = new Repository( sourceRepositoryId, source );
+            Repository targetRepository = new Repository( targetRepositoryId, target );
+            copier.copy( sourceRepository, targetRepository, version );
         }
         catch ( IOException e )
         {

Modified: maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/DefaultRepositoryCopier.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/DefaultRepositoryCopier.java?rev=570862&r1=570861&r2=570862&view=diff
==============================================================================
--- maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/DefaultRepositoryCopier.java (original)
+++ maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/DefaultRepositoryCopier.java Wed Aug 29 09:50:37 2007
@@ -79,24 +79,7 @@
 
     private Logger logger;
 
-    /**
-     * @deprecated use {@link #copy(String, Repository, String)} so the server configuration applies
-     */
-    public void copy( String sourceRepositoryUrl, String targetRepositoryUrl, String version )
-        throws WagonException, IOException
-    {
-        Repository targetRepository = new Repository( "target", targetRepositoryUrl );
-
-        copy( sourceRepositoryUrl, targetRepository, version );
-    }
-
-    public void copy( String sourceRepositoryUrl, Repository targetRepository, String version )
-        throws WagonException, IOException
-    {
-        copy( sourceRepositoryUrl, targetRepository, version, null );
-    }
-
-    public void copy( String sourceRepositoryUrl, Repository targetRepository, String version, String username )
+    public void copy( Repository sourceRepository, Repository targetRepository, String version )
         throws WagonException, IOException
     {
         String prefix = "staging-plugin";
@@ -123,13 +106,12 @@
 
         logger.info( "Downloading files from source repository." );
 
-        Repository sourceRepository = new Repository( "source", sourceRepositoryUrl );
-
         String protocol = sourceRepository.getProtocol();
 
-        Wagon sourceWagon = wagonManager.getWagon( protocol );
+        Wagon sourceWagon = wagonManager.getWagon( sourceRepository );
+        AuthenticationInfo sourceAuth = wagonManager.getAuthenticationInfo( sourceRepository.getId() );
 
-        sourceWagon.connect( sourceRepository );
+        sourceWagon.connect( sourceRepository, sourceAuth );
 
         List files = new ArrayList();
 
@@ -159,13 +141,10 @@
 
         logger.info( "Downloading metadata from the target repository." );
 
-        // TODO BUG for some reason it gets the wagon without authentication info
         Wagon targetWagon = wagonManager.getWagon( targetRepository );
+        AuthenticationInfo targetAuth = wagonManager.getAuthenticationInfo( targetRepository.getId() );
 
-        // @todo Work around the bug above
-        AuthenticationInfo authenticationInfo = new AuthenticationInfo();
-        authenticationInfo.setUserName( username );
-        targetWagon.connect( targetRepository, authenticationInfo );
+        targetWagon.connect( targetRepository, targetAuth );
 
         PrintWriter rw = new PrintWriter( new FileWriter( renameScript ) );
 

Modified: maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/RepositoryCopier.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/RepositoryCopier.java?rev=570862&r1=570861&r2=570862&view=diff
==============================================================================
--- maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/RepositoryCopier.java (original)
+++ maven/plugins/trunk/maven-stage-plugin/src/main/java/org/apache/maven/plugins/stage/RepositoryCopier.java Wed Aug 29 09:50:37 2007
@@ -39,15 +39,6 @@
 
     String MAVEN_METADATA = "maven-metadata.xml";
 
-    /**
-     * @deprecated use {@link #copy(String, Repository, String)} so the server configuration applies 
-     */
-    void copy( String source, String target, String version )
-        throws WagonException, IOException;
-
-    void copy( String sourceRepositoryUrl, Repository targetRepository, String version )
-        throws WagonException, IOException;
-
-    void copy( String sourceRepositoryUrl, Repository targetRepository, String version, String username )
+    void copy( Repository sourceRepository, Repository targetRepository, String version )
         throws WagonException, IOException;
 }

Modified: maven/plugins/trunk/maven-stage-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-stage-plugin/src/site/apt/index.apt?rev=570862&r1=570861&r2=570862&view=diff
==============================================================================
--- maven/plugins/trunk/maven-stage-plugin/src/site/apt/index.apt (original)
+++ maven/plugins/trunk/maven-stage-plugin/src/site/apt/index.apt Wed Aug 29 09:50:37 2007
@@ -35,14 +35,12 @@
 
 * Goals Overview
 
-   The Stage Plugin has one goals:
+   The Stage Plugin has one goal:
 
    * {{{copy-mojo.html}stage:copy}} Copies artifacts from one repository to the
    another repository.
 
-* Usage
-
-   Instructions on how to use the Stage Plugin can be found {{{usage.html}here}}.
+   Check the {{{usage.html}instructions on how to use the Stage Plugin}}.
 
  ~~ * Examples
 

Modified: maven/plugins/trunk/maven-stage-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-stage-plugin/src/site/apt/usage.apt?rev=570862&r1=570861&r2=570862&view=diff
==============================================================================
--- maven/plugins/trunk/maven-stage-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-stage-plugin/src/site/apt/usage.apt Wed Aug 29 09:50:37 2007
@@ -31,24 +31,27 @@
 
  The plugin is used from the command line. In the following example we will
  copy artifacts from a staging repository located at
- <<<http://people.apache.org/~snicoll/maven-stage-repo/>>> to the Apache rsync
- repository located at
- <<<scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository>>>.
+ <<<http://people.apache.org/~snicoll/maven-stage-repo/>>>
+ that is configured in the user settings file with an <<<apache.staging>>> id 
+ to the Apache scp repository located at
+ <<<scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository>>>
+ that is configured in the user settings file with an <<<apache.releases>>> id.
+ If no special configuration is required for the source or target repositories the
+ sourceRepositoryId or targetRepositoryId parameters respectively can be ommited
 
 -------------------
 mvn stage:copy -Dsource="http://people.apache.org/~snicoll/maven-stage-repo/" \
                -Dtarget="scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository" \
-               -Dversion=2.0.3
+               -DsourceRepositoryId=apache.staging \
+               -DtargetRepositoryId=apache.releases
 -------------------
 
- <<Note:>> Although it looks like we are only copying version <<<2.0.3>>>, we
- are in fact copying <<everything>> from the source URL to the target. This is
- due to a bug and will change in the future.
+ <<Note:>> we are copying <<everything>> from the source URL to the target.
 
 
 * What is happening under the hood?
 
- The follwing tasks will be performed by the plugin:
+ The following tasks will be performed by the plugin:
 
  * Download the files from the source repository
 

Modified: maven/plugins/trunk/maven-stage-plugin/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-stage-plugin/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java?rev=570862&r1=570861&r2=570862&view=diff
==============================================================================
--- maven/plugins/trunk/maven-stage-plugin/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java (original)
+++ maven/plugins/trunk/maven-stage-plugin/src/test/java/org/apache/maven/plugins/stage/RepositoryCopierTest.java Wed Aug 29 09:50:37 2007
@@ -5,6 +5,7 @@
 import org.codehaus.plexus.util.IOUtil;
 import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
 import org.apache.maven.artifact.repository.metadata.Metadata;
+import org.apache.maven.wagon.repository.Repository;
 
 import java.io.File;
 import java.io.Reader;
@@ -34,7 +35,10 @@
 
         File stagingRepo = new File( getBasedir(), "src/test/staging-repository" );
 
-        copier.copy( "file://" + stagingRepo, "scp://localhost/" + targetRepo, version );
+        Repository sourceRepository = new Repository( "source", "file://" + stagingRepo );
+        Repository targetRepository = new Repository( "target", "scp://localhost/" + targetRepo );
+
+        copier.copy( sourceRepository, targetRepository, version );
 
         String s[] = {
             "maven",