maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r586141 - in /maven/ant-tasks/trunk: sample.build.xml src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java src/main/java/org/apache/maven/artifact/ant/DeployTask.java
Date Thu, 18 Oct 2007 21:19:17 GMT
Author: hboutemy
Date: Thu Oct 18 14:19:16 2007
New Revision: 586141

URL: http://svn.apache.org/viewvc?rev=586141&view=rev
Log:
[MANTTASKS-23] add uniqueVersion="false" to artifact:deploy

Modified:
    maven/ant-tasks/trunk/sample.build.xml
    maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
    maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java

Modified: maven/ant-tasks/trunk/sample.build.xml
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/sample.build.xml?rev=586141&r1=586140&r2=586141&view=diff
==============================================================================
--- maven/ant-tasks/trunk/sample.build.xml (original)
+++ maven/ant-tasks/trunk/sample.build.xml Thu Oct 18 14:19:16 2007
@@ -29,7 +29,8 @@
 
     <artifact:localRepository id="local.repository" path="${basedir}/target/local-repo"
layout="default"/>
 
-    <artifact:remoteRepository id="deploy.repository" url="file://localhost/${basedir}/target/deployment-repo"
layout="default"/>
+    <property name="deploy.repository.url" value="${basedir}/target/deployment-repo" />
+    <artifact:remoteRepository id="deploy.repository" url="file://localhost/${deploy.repository.url}"
layout="default"/>
 
     <artifact:pom file="pom.xml" id="maven.project"/>
   </target>
@@ -163,6 +164,8 @@
 
   <target name="test-deploy" depends="initTaskDefs,installSshProvider">
     <property name="outJar" value="${maven.project.build.directory}/${maven.project.build.finalName}.jar"/>
+    <property name="targetDir" value="${deploy.repository.url}/org/apache/maven/maven-ant-tasks/${pom.xml.project.version}"/>
+    <delete dir="${deploy.repository.url}"/>
 
     <artifact:install file="${outJar}">
       <pom refid="maven.project"/>
@@ -173,6 +176,17 @@
       <remoteSnapshotRepository refid="deploy.repository"/>
       <pom refid="maven.project"/>
     </artifact:deploy>
+    <available file="${targetDir}" property="deploymentArtifactDir"/>
+    <fail unless="deploymentArtifactDir">deployment in ${deploy.repository.url} should
have created a directory</fail>
+    <available file="${targetDir}/maven-ant-tasks-${pom.xml.project.version}.jar" property="outJarWithoutUniqueVersion"/>
+    <fail if="outJarWithoutUniqueVersion">uniqueVersion="true" by default: file -SNAPSHOT.jar
should not exist</fail>
+
+    <artifact:deploy file="${outJar}" uniqueVersion="false">
+      <remoteSnapshotRepository refid="deploy.repository"/>
+      <pom refid="maven.project"/>
+    </artifact:deploy>
+    <available file="${targetDir}/maven-ant-tasks-${pom.xml.project.version}.jar" property="outJarWithoutUniqueVersion"/>
+    <fail unless="outJarWithoutUniqueVersion">when uniqueVersion="false", file -SNAPSHOT.jar
should be created</fail>
 
     <artifact:deploy file="${outJar}">
       <remoteRepository url="scp://localhost/tmp/deployment-repo">

Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?rev=586141&r1=586140&r2=586141&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
(original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
Thu Oct 18 14:19:16 2007
@@ -92,15 +92,13 @@
     }
 
     /**
-     * Create a core-Maven ArtifactRepository from a Maven Ant Tasks's RemoteRepository definition.
+     * Create a core-Maven ArtifactRepositoryFactory from a Maven Ant Tasks's RemoteRepository
definition,
+     * eventually configured with authentication and proxy information.
      * @param repository the remote repository as defined in Ant
-     * @return the corresponding ArtifactRepository
+     * @return the corresponding ArtifactRepositoryFactory
      */
-    protected ArtifactRepository createRemoteArtifactRepository( RemoteRepository repository
)
+    protected ArtifactRepositoryFactory getArtifactRepositoryFactory( RemoteRepository repository
)
     {
-        ArtifactRepositoryLayout repositoryLayout =
-            (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, repository.getLayout()
);
-
         WagonManager manager = (WagonManager) lookup( WagonManager.ROLE );
 
         Authentication authentication = repository.getAuthentication();
@@ -118,13 +116,38 @@
                               proxy.getPassword(), proxy.getNonProxyHosts() );
         }
 
+        return (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
+    }
+
+    protected void releaseArtifactRepositoryFactory( ArtifactRepositoryFactory repositoryFactory
)
+    {
+        try
+        {
+            getContainer().release( repositoryFactory );
+        }
+        catch ( ComponentLifecycleException e )
+        {
+            // TODO: Warn the user, or not?
+        }
+    }
+
+    /**
+     * Create a core-Maven ArtifactRepository from a Maven Ant Tasks's RemoteRepository definition.
+     * @param repository the remote repository as defined in Ant
+     * @return the corresponding ArtifactRepository
+     */
+    protected ArtifactRepository createRemoteArtifactRepository( RemoteRepository repository
)
+    {
+        ArtifactRepositoryLayout repositoryLayout =
+            (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, repository.getLayout()
);
+
         ArtifactRepositoryFactory repositoryFactory = null;
 
         ArtifactRepository artifactRepository;
 
         try
         {
-            repositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE
);
+            repositoryFactory = getArtifactRepositoryFactory( repository );
 
             ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repository.getSnapshots()
);
             ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repository.getReleases()
);
@@ -134,14 +157,7 @@
         }
         finally
         {
-            try
-            {
-                getContainer().release( repositoryFactory );
-            }
-            catch ( ComponentLifecycleException e )
-            {
-                // TODO: Warn the user, or not?
-            }
+            releaseArtifactRepositoryFactory( repositoryFactory );
         }
 
         return artifactRepository;

Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java?rev=586141&r1=586140&r2=586141&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java Thu
Oct 18 14:19:16 2007
@@ -24,6 +24,8 @@
 import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.model.DistributionManagement;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.apache.tools.ant.BuildException;
@@ -43,6 +45,38 @@
 
     private RemoteRepository remoteSnapshotRepository;
 
+    private boolean uniqueVersion = true;
+
+    /**
+     * Create a core-Maven deployment ArtifactRepository from a Maven Ant Tasks's RemoteRepository
definition.
+     * @param repository the remote repository as defined in Ant
+     * @return the corresponding ArtifactRepository
+     */
+    protected ArtifactRepository createDeploymentArtifactRepository( RemoteRepository repository
)
+    {
+        ArtifactRepositoryLayout repositoryLayout =
+            (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, repository.getLayout()
);
+
+        ArtifactRepositoryFactory repositoryFactory = null;
+
+        ArtifactRepository artifactRepository;
+
+        try
+        {
+            repositoryFactory = getArtifactRepositoryFactory( repository );
+
+            artifactRepository = repositoryFactory.createDeploymentArtifactRepository( repository.getId(),
repository.getUrl(),
+                                                                             repositoryLayout,
uniqueVersion );
+        }
+        finally
+        {
+            releaseArtifactRepositoryFactory( repositoryFactory );
+        }
+
+        return artifactRepository;
+    }
+
+
     protected void doExecute()
     {
         ArtifactRepository localRepo = createLocalArtifactRepository();
@@ -110,6 +144,7 @@
                 {
                     remoteSnapshotRepository = createAntRemoteRepositoryBase( distributionManagement
                         .getSnapshotRepository() );
+                    uniqueVersion = distributionManagement.getSnapshotRepository().isUniqueVersion();
                 }
                 if ( distributionManagement.getRepository() != null )
                 {
@@ -126,11 +161,11 @@
         ArtifactRepository deploymentRepository;
         if ( artifact.isSnapshot() && remoteSnapshotRepository != null )
         {
-            deploymentRepository = createRemoteArtifactRepository( remoteSnapshotRepository
);
+            deploymentRepository = createDeploymentArtifactRepository( remoteSnapshotRepository
);
         }
         else if ( remoteRepository != null )
         {
-            deploymentRepository = createRemoteArtifactRepository( remoteRepository );
+            deploymentRepository = createDeploymentArtifactRepository( remoteRepository );
         }
         else
         {
@@ -154,5 +189,15 @@
     public void addRemoteRepository( RemoteRepository remoteRepository )
     {
         this.remoteRepository = remoteRepository;
+    }
+
+    public void setUniqueVersion( boolean uniqueVersion )
+    {
+        this.uniqueVersion = uniqueVersion;
+    }
+
+    public boolean getUniqueVersion()
+    {
+        return uniqueVersion;
     }
 }



Mime
View raw message