Author: stephenc Date: Tue Jun 21 08:37:12 2011 New Revision: 1137908 URL: http://svn.apache.org/viewvc?rev=1137908&view=rev Log: [MGPG-38] Allow deployment of multiple side artifacts at the same time via the CLI
Added: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/ - copied from r1128595, maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-file-with-extras/ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test-src.tar.gz - copied unchanged from r1137904, maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1-src.tar.gz maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.tar.gz - copied unchanged from r1137904, maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.tar.gz maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.zip - copied unchanged from r1137904, maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-jar-with-extras/test-0.1.zip Modified: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.pom maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.properties maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/verify.bsh maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java Modified: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.pom URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.pom?rev=1137908&r1=1128595&r2=1137908&view=diff ============================================================================== --- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.pom (original) +++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.pom Tue Jun 21 08:37:12 2011 @@ -22,7 +22,7 @@ under the License. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven.its.gpg.sadfwe</groupId> + <groupId>org.apache.maven.its.gpg.sadfs</groupId> <artifactId>test</artifactId> <version>1.0</version> <packaging>jar</packaging> Modified: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.properties?rev=1137908&r1=1128595&r2=1137908&view=diff ============================================================================== --- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.properties (original) +++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/test.properties Tue Jun 21 08:37:12 2011 @@ -21,3 +21,6 @@ url = file:target/repo gpg.passphrase = TEST sources = test-sources.jar javadoc = test-javadoc.jar +files = test.zip,test-src.tar.gz,test.tar.gz +types = zip,tar.gz,tar.gz +classifiers = ,src, Modified: maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/verify.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/verify.bsh?rev=1137908&r1=1128595&r2=1137908&view=diff ============================================================================== --- maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/verify.bsh (original) +++ maven/plugins/trunk/maven-gpg-plugin/src/it/sign-and-deploy-files/verify.bsh Tue Jun 21 08:37:12 2011 @@ -20,7 +20,7 @@ import java.io.*; -File artifactDir = new File( basedir, "target/repo/org/apache/maven/its/gpg/sadfwe/test/1.0" ); +File artifactDir = new File( basedir, "target/repo/org/apache/maven/its/gpg/sadfs/test/1.0" ); String[] expectedFiles = { "test-1.0.jar", @@ -31,6 +31,12 @@ String[] expectedFiles = { "test-1.0-javadoc.jar.asc", "test-1.0.pom", "test-1.0.pom.asc", + "test-1.0.zip", + "test-1.0.zip.asc", + "test-1.0-src.tar.gz", + "test-1.0-src.tar.gz.asc", + "test-1.0.tar.gz", + "test-1.0.tar.gz.asc", }; for ( String expectedFile : expectedFiles ) Modified: maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java?rev=1137908&r1=1137907&r2=1137908&view=diff ============================================================================== --- maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java (original) +++ maven/plugins/trunk/maven-gpg-plugin/src/main/java/org/apache/maven/plugin/gpg/SignAndDeployFileMojo.java Tue Jun 21 08:37:12 2011 @@ -271,6 +271,30 @@ public class SignAndDeployFileMojo */ protected boolean updateReleaseInfo; + /** + * 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; + private void initProperties() throws MojoExecutionException { @@ -380,6 +404,88 @@ public class SignAndDeployFileMojo 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(); )