You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by pg...@apache.org on 2009/11/25 23:25:22 UTC
svn commit: r884304 - in /maven/ant-tasks/trunk/src:
main/java/org/apache/maven/artifact/ant/ site/apt/
Author: pgier
Date: Wed Nov 25 22:25:22 2009
New Revision: 884304
URL: http://svn.apache.org/viewvc?rev=884304&view=rev
Log:
[MANTTASKS-151] Allow a jar with classifier to be deployed without a main project jar.
Modified:
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DeployTask.java
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallDeployTaskSupport.java
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallTask.java
maven/ant-tasks/trunk/src/site/apt/reference.apt
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=884304&r1=884303&r2=884304&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 Wed Nov 25 22:25:22 2009
@@ -29,6 +29,7 @@
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
import java.util.Iterator;
@@ -88,6 +89,12 @@
protected void doExecute()
{
+ if ( file == null && ( attachedArtifacts.size() == 0 ) )
+ {
+ throw new BuildException( "You must specify a file and/or an attached artifact "
+ + "to deploy to the repository." );
+ }
+
ArtifactRepository localRepo = createLocalArtifactRepository();
Pom pom = initializePom( localRepo );
@@ -109,22 +116,20 @@
ArtifactRepository deploymentRepository = getDeploymentRepository( pom, artifact );
- log( "Deploying to " + deploymentRepository.getUrl() );
+ log( "Deploying to " + deploymentRepository.getUrl(), Project.MSG_INFO );
ArtifactDeployer deployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE );
try
{
- if ( !isPomArtifact )
+ if ( file != null )
{
- if ( file == null )
+ if ( !isPomArtifact )
{
- throw new BuildException( "You must specify a file to deploy to the repository." );
+ deployer.deploy( file, artifact, deploymentRepository, localRepo );
+ }
+ else
+ {
+ deployer.deploy( pom.getFile(), artifact, deploymentRepository, localRepo );
}
-
- deployer.deploy( file, artifact, deploymentRepository, localRepo );
- }
- else
- {
- deployer.deploy( pom.getFile(), artifact, deploymentRepository, localRepo );
}
// Deploy any attached artifacts
Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallDeployTaskSupport.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallDeployTaskSupport.java?rev=884304&r1=884303&r2=884304&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallDeployTaskSupport.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallDeployTaskSupport.java Wed Nov 25 22:25:22 2009
@@ -20,9 +20,9 @@
*/
import java.io.File;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.ArrayList;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -35,9 +35,15 @@
public abstract class InstallDeployTaskSupport
extends AbstractArtifactTask
{
+ /**
+ * The file to install/deploy.
+ */
protected File file;
- protected List attachedArtifacts;
+ /**
+ * Additional attached artifacts to install/deploy
+ */
+ protected List attachedArtifacts = new ArrayList();
public File getFile()
{
@@ -70,11 +76,6 @@
public AttachedArtifact createAttach()
{
- if ( attachedArtifacts == null )
- {
- attachedArtifacts = new ArrayList();
- }
-
AttachedArtifact attach = new AttachedArtifact();
attachedArtifacts.add( attach );
Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallTask.java?rev=884304&r1=884303&r2=884304&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallTask.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/InstallTask.java Wed Nov 25 22:25:22 2009
@@ -41,6 +41,12 @@
{
protected void doExecute()
{
+ if ( file == null && ( attachedArtifacts.size() == 0 ) )
+ {
+ throw new BuildException( "You must specify a file and/or an attached artifact "
+ + "to install to the local repository." );
+ }
+
ArtifactRepository localRepo = createLocalArtifactRepository();
Pom pom = initializePom( localRepo );
@@ -62,18 +68,16 @@
ArtifactInstaller installer = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE );
try
{
- if ( !isPomArtifact )
+ if ( file != null )
{
- if ( file == null )
+ if ( !isPomArtifact )
{
- throw new BuildException( "You must specify a file to install to the local repository." );
+ installer.install( file, artifact, localRepo );
+ }
+ else
+ {
+ installer.install( pom.getFile(), artifact, localRepo );
}
-
- installer.install( file, artifact, localRepo );
- }
- else
- {
- installer.install( pom.getFile(), artifact, localRepo );
}
// Install any attached artifacts
Modified: maven/ant-tasks/trunk/src/site/apt/reference.apt
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/site/apt/reference.apt?rev=884304&r1=884303&r2=884304&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/site/apt/reference.apt (original)
+++ maven/ant-tasks/trunk/src/site/apt/reference.apt Wed Nov 25 22:25:22 2009
@@ -127,9 +127,9 @@
*---------------------+--------------------------------------------------------------------------+-------------------------------------------------+-------------+
| <<Attribute>> | <<Description>> | <<Required>> | << Since >> |
*---------------------+--------------------------------------------------------------------------+-------------------------------------------------+-------------+
-| <<<file>>> | The file to install in the repository. | Yes, except if packaging is <<<pom>>> | |
+| <<<file>>> | The file to install in the repository. | Yes, unless an attached artifact is specified | |
*---------------------+--------------------------------------------------------------------------+-------------------------------------------------+-------------+
-| <<<pomRefId>>> | The reference ID from a POM datatype defined earlier in the build file. | No, if a <<<pom>>> nested element is provided instead | |
+| <<<pomRefId>>> | The reference ID from a POM datatype defined earlier in the build file. | Yes, unless a <<<pom>>> nested element is provided instead | |
*---------------------+--------------------------------------------------------------------------+-------------------------------------------------+-------------+
| <<<settingsFile>>> | The settings file to use. Defaults to <<<$\{user.home\}/.ant/settings.xml>>> or if that doesn't exist <<<$\{user.home\}/.m2/settings.xml>>>. | No | 2.0.6 |
*---------------------+--------------------------------------------------------------------------+-------------------------------------------------+-------------+