maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arami...@apache.org
Subject svn commit: r407170 - in /maven/plugins/trunk/maven-deploy-plugin/src: main/java/org/apache/maven/plugin/deploy/ test/java/org/apache/maven/plugin/deploy/ test/resources/unit/deploy-file-legacy-repository-layout/ test/resources/unit/deploy-file-legacy-...
Date Wed, 17 May 2006 06:11:09 GMT
Author: aramirez
Date: Tue May 16 23:11:08 2006
New Revision: 407170

URL: http://svn.apache.org/viewcvs?rev=407170&view=rev
Log:
Modified the code to support alternative repository layouts

Added:
    maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/
    maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml
    maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/target/
    maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar
Modified:
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
    maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java

Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java?rev=407170&r1=407169&r2=407170&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
(original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
Tue May 16 23:11:08 2006
@@ -40,6 +40,7 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Reader;
+import java.util.Map;
 
 /**
  * Installs the artifact in the remote repository.
@@ -94,22 +95,18 @@
      * @required
      */
     private String repositoryId;
-    
+
     /**
      * The type of remote repository layout to deploy to. Try <i>legacy</i> for
a Maven 1.x-style repository layout.
      * @parameter expression="${repositoryLayout}" default-value="default"
      * @required
      */
     private String repositoryLayout;
-    
+
     /**
-     * Current session, for looking up repository layout instances, etc.
-     * 
-     * @parameter default-value="${session}"
-     * @required
-     * @readonly
+     * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
      */
-    private MavenSession session;
+    private Map repositoryLayouts;
 
     /**
      * URL where the artifact will be deployed. <br/>
@@ -124,19 +121,11 @@
      * @component
      */
     private ArtifactFactory artifactFactory;
-    
+
     /**
      * @component
      */
     private ArtifactRepositoryFactory repositoryFactory;
-    
-    /**
-     * This is a concession to keep the unit tests running.
-     * @todo REMOVE!
-     * 
-     * @component
-     */
-    private ArtifactRepositoryLayout defaultLayout;
 
     /**
      * @parameter expression="${pomFile}"
@@ -166,7 +155,6 @@
      */
     private boolean uniqueVersion;
 
-
     protected void initProperties()
         throws MojoExecutionException
     {
@@ -196,26 +184,10 @@
         {
             throw new MojoExecutionException( file.getPath() + " not found." );
         }
-        
+
         ArtifactRepositoryLayout layout;
-        
-        // FIXME: We shouldn't have to do this, since the session is @required, but the testing
harness cannot populate it...
-        if ( session != null )
-        {
-            try
-            {
-                System.out.println( "Session is: " + session );
-                layout = (ArtifactRepositoryLayout) session.lookup( ArtifactRepositoryLayout.ROLE,
repositoryLayout );
-            }
-            catch ( ComponentLookupException e )
-            {
-                throw new MojoExecutionException( "Failed to lookup repository layout: \'"
+ repositoryLayout + "\'. Perhaps you meant 'default' or 'legacy'? Error: " + e.getMessage(),
e );
-            }
-        }
-        else
-        {
-            layout = defaultLayout;
-        }
+
+        layout = ( ArtifactRepositoryLayout ) repositoryLayouts.get( repositoryLayout );
 
         ArtifactRepository deploymentRepository =
             repositoryFactory.createDeploymentArtifactRepository( repositoryId, url, layout,
uniqueVersion );

Modified: maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java?rev=407170&r1=407169&r2=407170&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
(original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugin/deploy/DeployFileMojoTest.java
Tue May 16 23:11:08 2006
@@ -249,6 +249,62 @@
         assertTrue( file.exists() );
     }
 
+    public void testDeployIfRepositoryLayoutIsLegacy()
+        throws Exception
+    {
+        File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-legacy-repository-layout/plugin-config.xml"
);
+
+        DeployFileMojo mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom );
+
+        assertNotNull( mojo );
+
+        String repositoryLayout = (String) getVariableValueFromObject(  mojo, "repositoryLayout"
);
+
+        String groupId = (String) getVariableValueFromObject( mojo, "groupId" );
+
+        String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" );
+
+        String version = (String) getVariableValueFromObject( mojo, "version" );
+
+        assertEquals( "legacy", repositoryLayout );
+
+        mojo.execute();
+
+        File artifactFile = new File( remoteRepo, "deploy-file-legacy-repository-layout/"
+ groupId + "/jars/" + artifactId + "-" + version + ".jar" );
+
+        assertTrue( artifactFile.exists() );
+
+        //check the remote-repo
+        expectedFiles = new ArrayList();
+        fileList = new ArrayList();
+
+        File repo = new File( remoteRepo, "deploy-file-legacy-repository-layout" );
+
+        File[] files = repo.listFiles();
+
+        for ( int i = 0; i < files.length; i++ )
+        {
+            addFileToList( files[i], fileList );
+        }
+
+        expectedFiles.add( "org.apache.maven.test" );
+        expectedFiles.add( "jars" );
+        expectedFiles.add( "maven-deploy-file-test-1.0.jar" );
+        expectedFiles.add( "maven-deploy-file-test-1.0.jar.md5" );
+        expectedFiles.add( "maven-deploy-file-test-1.0.jar.sha1" );
+        expectedFiles.add( "poms" );
+        expectedFiles.add( "maven-deploy-file-test-1.0.pom" );
+        expectedFiles.add( "maven-deploy-file-test-1.0.pom.md5" );
+        expectedFiles.add( "maven-deploy-file-test-1.0.pom.sha1" );
+        expectedFiles.add( "maven-metadata.xml" );
+        expectedFiles.add( "maven-metadata.xml.md5" );
+        expectedFiles.add( "maven-metadata.xml.sha1" );
+
+        assertEquals( expectedFiles.size(), fileList.size() );
+
+        assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) );
+    }
+
     private void addFileToList( File file, List fileList )
     {
         if ( !file.isDirectory() )

Added: maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml?rev=407170&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml
(added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/plugin-config.xml
Tue May 16 23:11:08 2006
@@ -0,0 +1,21 @@
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-deploy-plugin</artifactId>
+		<configuration>
+		  <groupId>org.apache.maven.test</groupId>
+		  <artifactId>maven-deploy-file-test</artifactId>
+		  <version>1.0</version>
+		  <packaging>jar</packaging>
+		  <file>${basedir}/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar</file>
+		  <repositoryId>deploy-test</repositoryId>
+		  <url>file://${basedir}/target/remote-repo/deploy-file-legacy-repository-layout</url>
+		  <uniqueVersion>true</uniqueVersion>
+		  <localRepository>${localRepository}</localRepository>
+		  <repositoryLayout>legacy</repositoryLayout>
+		</configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar?rev=407170&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar
(added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/test/resources/unit/deploy-file-legacy-repository-layout/target/deploy-test-file-1.0-SNAPSHOT.jar
Tue May 16 23:11:08 2006
@@ -0,0 +1 @@
+This is not an actual jar
\ No newline at end of file



Mime
View raw message