Author: stephenc
Date: Tue Jun 21 08:25:23 2011
New Revision: 1137904
URL: http://svn.apache.org/viewvc?rev=1137904&view=rev
Log:
[MDEPLOY-137] Allow deployment of multiple side artifacts at the same time via
the CLI
Added:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/
- copied from r1126356,
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-without-pom/
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1-src.tar.gz
(with props)
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.tar.gz
(with props)
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.zip
(with props)
Modified:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test.properties
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/verify.bsh
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
Added:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1-src.tar.gz
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1-src.tar.gz?rev=1137904&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1-src.tar.gz
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.tar.gz
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.tar.gz?rev=1137904&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.tar.gz
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.zip
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.zip?rev=1137904&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.zip
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test.properties
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test.properties?rev=1137904&r1=1126356&r2=1137904&view=diff
==============================================================================
---
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test.properties
(original)
+++
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test.properties
Tue Jun 21 08:25:23 2011
@@ -6,3 +6,6 @@ artifactId = test
version = 1.0
packaging = jar
generatePom = false
+files = test-0.1.zip,test-0.1-src.tar.gz,test-0.1.tar.gz
+types = zip,tar.gz,tar.gz
+classifiers = ,src,
Modified:
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/verify.bsh
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/verify.bsh?rev=1137904&r1=1126356&r2=1137904&view=diff
==============================================================================
---
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/verify.bsh
(original)
+++
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/verify.bsh
Tue Jun 21 08:25:23 2011
@@ -5,6 +5,9 @@ String[] paths =
{
"org/apache/maven/its/deploy/tpjwop/test/maven-metadata.xml",
"org/apache/maven/its/deploy/tpjwop/test/1.0/test-1.0.jar",
+ "org/apache/maven/its/deploy/tpjwop/test/1.0/test-1.0.zip",
+ "org/apache/maven/its/deploy/tpjwop/test/1.0/test-1.0-src.tar.gz",
+ "org/apache/maven/its/deploy/tpjwop/test/1.0/test-1.0.tar.gz",
};
for ( String path : paths )
Modified:
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java?rev=1137904&r1=1137903&r2=1137904&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 Jun 21 08:25:23 2011
@@ -47,6 +47,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
+import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.List;
@@ -203,6 +204,30 @@ public class DeployFileMojo
*/
private ModelValidator modelValidator;
+ /**
+ * A comma separated list of types for each of the extra side artifacts to
deploy. If there is a mis-match in
+ * the number of entries in {@link #files} or {@link #classifiers}, then
an error will be raised.
+ *
+ * @parameter expression="${types}";
+ */
+ private String types;
+
+ /**
+ * A comma separated list of classifiers for each of the extra side
artifacts to deploy. If there is a mis-match in
+ * the number of entries in {@link #files} or {@link #types}, then an
error will be raised.
+ *
+ * @parameter expression="${classifiers}";
+ */
+ private String classifiers;
+
+ /**
+ * A comma separated list of files for each of the extra side artifacts to
deploy. If there is a mis-match in
+ * the number of entries in {@link #types} or {@link #classifiers}, then
an error will be raised.
+ *
+ * @parameter expression="${files}"
+ */
+ private String files;
+
void initProperties()
throws MojoExecutionException
{
@@ -298,6 +323,88 @@ public class DeployFileMojo
projectHelper.attachArtifact( project, "jar", "javadoc", javadoc );
}
+ if ( files != null )
+ {
+ if ( types == null )
+ {
+ throw new MojoExecutionException( "You must specify 'types' if
you specify 'files'" );
+ }
+ if ( classifiers == null )
+ {
+ throw new MojoExecutionException( "You must specify
'classifiers' if you specify 'files'" );
+ }
+ int filesLength = StringUtils.countMatches( files, "," );
+ int typesLength = StringUtils.countMatches( types, "," );
+ int classifiersLength = StringUtils.countMatches( classifiers, ","
);
+ if ( typesLength != filesLength )
+ {
+ throw new MojoExecutionException( "You must specify the same
number of entries in 'files' and " +
+ "'types' (respectively " + filesLength + " and " +
typesLength + " entries )" );
+ }
+ if ( classifiersLength != filesLength )
+ {
+ throw new MojoExecutionException( "You must specify the same
number of entries in 'files' and " +
+ "'classifiers' (respectively " + filesLength + " and "
+ classifiersLength + " entries )" );
+ }
+ int fi = 0;
+ int ti = 0;
+ int ci = 0;
+ for ( int i = 0; i <= filesLength; i++ )
+ {
+ int nfi = files.indexOf( ',', fi );
+ if ( nfi == -1 )
+ {
+ nfi = files.length();
+ }
+ int nti = types.indexOf( ',', ti );
+ if ( nti == -1 )
+ {
+ nti = types.length();
+ }
+ int nci = classifiers.indexOf( ',', ci );
+ if ( nci == -1 )
+ {
+ nci = classifiers.length();
+ }
+ File file = new File( files.substring( fi, nfi ) );
+ if ( !file.isFile() )
+ {
+ // try relative to the project basedir just in case
+ file = new File( project.getBasedir(), files.substring(
fi, nfi ) );
+ }
+ if ( file.isFile() )
+ {
+ if ( StringUtils.isWhitespace( classifiers.substring( ci,
nci ) ) )
+ {
+ projectHelper.attachArtifact( project,
types.substring( ti, nti ).trim(), file );
+ }
+ else
+ {
+ projectHelper.attachArtifact( project,
types.substring( ti, nti).trim(),
+ classifiers.substring( ci, nci ).trim(), file);
+ }
+ }
+ else
+ {
+ throw new MojoExecutionException( "Specified side artifact
" + file + " does not exist" );
+ }
+ fi = nfi + 1;
+ ti = nti + 1;
+ ci = nci + 1;
+ }
+ }
+ else
+ {
+ if ( types != null )
+ {
+ throw new MojoExecutionException( "You must specify 'files' if
you specify 'types'" );
+ }
+ if ( classifiers != null )
+ {
+ throw new MojoExecutionException( "You must specify 'files' if
you specify 'classifiers'" );
+ }
+ }
+
List attachedArtifacts = project.getAttachedArtifacts();
for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )