You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2011/06/21 10:25:23 UTC

svn commit: r1137904 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/3rd-party-jar-with-extras/ main/java/org/apache/maven/plugin/deploy/

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(); )



Re: svn commit: r1137904 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/3rd-party-jar-with-extras/ main/java/org/apache/maven/plugin/deploy/

Posted by Stephen Connolly <st...@gmail.com>.
Or are you talking about when people are configuring within the pom

in which case I don't mind prefixing them with

forCliUseOnly

so that the configuration block would be

<configuration>
  <forCliUseOnlyFiles>...</forCliUSeOnlyFiles>
</configuration>

but it's still tied to the property "files" so that on the CLI I just type
-Dfiles=...

On 23 June 2011 10:15, Stephen Connolly <st...@gmail.com>wrote:

> This is for the CLI
>
> mvn deploy:deploy-file -Dpom=myart.pom -Dfile=myart.jar
> -Dsources=myart-sources.jar -Djavadoc=myart-javadoc.jar
> -Dfiles=myart-src.zip,myart-src.tar.gz,myart-bin.zip,myart-bin.tar.gz
> -Dtypes=zip,tar.gz,zip,tar,gz -Dclassifiers=src,src,bin,bin
>
> Do we really want to force people to type out a lot lot more
>
>
> On 23 June 2011 09:41, Brett Porter <br...@apache.org> wrote:
>
>> On 21/06/2011, at 4:25 PM, stephenc@apache.org wrote:
>>
>> > 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
>> >
>> [snip]
>> > +    /**
>> > +     * 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;
>>
>> Given these are so closely tied together - would it be better to use a
>> list of <attachedArtifacts> each with <file> <type> and <classifier> ? I
>> know it's more verbose, but probably less error prone.
>>
>> Either way, I think these args should have something more on the front -
>> attachedFiles or extraFiles, or similar.
>>
>> - Brett
>>
>> --
>> Brett Porter
>> brett@apache.org
>> http://brettporter.wordpress.com/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>
>

Re: svn commit: r1137904 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/3rd-party-jar-with-extras/ main/java/org/apache/maven/plugin/deploy/

Posted by Stephen Connolly <st...@gmail.com>.
On 23 June 2011 10:47, Stephen Connolly <st...@gmail.com>wrote:

> the only really safe separators I see are , ; / and \
>
>
And they're not 100% safe anyway

Otherwise xargs wouldn't need that \0 terminator mode

Re: svn commit: r1137904 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/3rd-party-jar-with-extras/ main/java/org/apache/maven/plugin/deploy/

Posted by Stephen Connolly <st...@gmail.com>.
Can you file a jira for that and assign it to me... I'll think about how to
tweak that for the single property case...

inferring file type is tricky... e.g. .tar.gz

and you really need two clear separators or else you end up with something
like

; as the item sep

filename,type/classifier

e.g.

-DextraFiles=foo-bin.tgz,tar.gz/bin;foo-src.tgz,tar.gz/src

could put the classifier up front

-DextraFiles=src=foo-src.tgz,tar.gz;bin=foo-bin.tar.gz,tar.gz;

could put the classifier in []'s

-DextraFiles=[src]foo-src.tgz,tar.gz;[bin]foo-bin.tgz,tar.gz

but [ is a valid file character on some OSes

the only really safe separators I see are , ; / and \



On 23 June 2011 10:25, Brett Porter <br...@apache.org> wrote:

>
> On 23/06/2011, at 5:15 PM, Stephen Connolly wrote:
>
> > This is for the CLI
> >
> > mvn deploy:deploy-file -Dpom=myart.pom -Dfile=myart.jar
> > -Dsources=myart-sources.jar -Djavadoc=myart-javadoc.jar
> > -Dfiles=myart-src.zip,myart-src.tar.gz,myart-bin.zip,myart-bin.tar.gz
> > -Dtypes=zip,tar.gz,zip,tar,gz -Dclassifiers=src,src,bin,bin
>
> Sorry, my mistake in that I didn't realise it was deploy:deploy-file.
>
> I would really rather specify them in sequence together somehow, maybe:
> -Dattach=myart-src.zip,zip,src;myart-src.tar.gz,tar.gz,src;myart-bin.zip,zip,bin;myart-bin.tar.gz,tar.gz,bin
>
> Then perhaps there are ways to make type/classifier optional by deriving
> them from the filename by default?
>
> - Brett
>
> --
> Brett Porter
> brett@apache.org
> http://brettporter.wordpress.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: svn commit: r1137904 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/3rd-party-jar-with-extras/ main/java/org/apache/maven/plugin/deploy/

Posted by Brett Porter <br...@apache.org>.
On 23/06/2011, at 5:15 PM, Stephen Connolly wrote:

> This is for the CLI
> 
> mvn deploy:deploy-file -Dpom=myart.pom -Dfile=myart.jar
> -Dsources=myart-sources.jar -Djavadoc=myart-javadoc.jar
> -Dfiles=myart-src.zip,myart-src.tar.gz,myart-bin.zip,myart-bin.tar.gz
> -Dtypes=zip,tar.gz,zip,tar,gz -Dclassifiers=src,src,bin,bin

Sorry, my mistake in that I didn't realise it was deploy:deploy-file.

I would really rather specify them in sequence together somehow, maybe: -Dattach=myart-src.zip,zip,src;myart-src.tar.gz,tar.gz,src;myart-bin.zip,zip,bin;myart-bin.tar.gz,tar.gz,bin

Then perhaps there are ways to make type/classifier optional by deriving them from the filename by default?

- Brett

--
Brett Porter
brett@apache.org
http://brettporter.wordpress.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r1137904 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/3rd-party-jar-with-extras/ main/java/org/apache/maven/plugin/deploy/

Posted by Stephen Connolly <st...@gmail.com>.
This is for the CLI

mvn deploy:deploy-file -Dpom=myart.pom -Dfile=myart.jar
-Dsources=myart-sources.jar -Djavadoc=myart-javadoc.jar
-Dfiles=myart-src.zip,myart-src.tar.gz,myart-bin.zip,myart-bin.tar.gz
-Dtypes=zip,tar.gz,zip,tar,gz -Dclassifiers=src,src,bin,bin

Do we really want to force people to type out a lot lot more

On 23 June 2011 09:41, Brett Porter <br...@apache.org> wrote:

> On 21/06/2011, at 4:25 PM, stephenc@apache.org wrote:
>
> > 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
> >
> [snip]
> > +    /**
> > +     * 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;
>
> Given these are so closely tied together - would it be better to use a list
> of <attachedArtifacts> each with <file> <type> and <classifier> ? I know
> it's more verbose, but probably less error prone.
>
> Either way, I think these args should have something more on the front -
> attachedFiles or extraFiles, or similar.
>
> - Brett
>
> --
> Brett Porter
> brett@apache.org
> http://brettporter.wordpress.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: svn commit: r1137904 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/3rd-party-jar-with-extras/ main/java/org/apache/maven/plugin/deploy/

Posted by Brett Porter <br...@apache.org>.
On 21/06/2011, at 4:25 PM, stephenc@apache.org wrote:

> 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
> 
[snip]
> +    /**
> +     * 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;

Given these are so closely tied together - would it be better to use a list of <attachedArtifacts> each with <file> <type> and <classifier> ? I know it's more verbose, but probably less error prone.

Either way, I think these args should have something more on the front - attachedFiles or extraFiles, or similar.

- Brett

--
Brett Porter
brett@apache.org
http://brettporter.wordpress.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org