Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5FFE218CB9 for ; Fri, 18 Dec 2015 17:40:25 +0000 (UTC) Received: (qmail 85774 invoked by uid 500); 18 Dec 2015 17:40:25 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 85723 invoked by uid 500); 18 Dec 2015 17:40:25 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 85714 invoked by uid 99); 18 Dec 2015 17:40:25 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Dec 2015 17:40:25 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id C2C231A12D7 for ; Fri, 18 Dec 2015 17:40:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.246 X-Spam-Level: * X-Spam-Status: No, score=1.246 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id jN9S2VSxvJMc for ; Fri, 18 Dec 2015 17:40:23 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 01AF9203F5 for ; Fri, 18 Dec 2015 17:40:23 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7C8B1E0053 for ; Fri, 18 Dec 2015 17:40:22 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 438023A019A for ; Fri, 18 Dec 2015 17:40:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1720830 - in /maven/plugins/trunk/maven-jar-plugin/src: main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java main/java/org/apache/maven/plugins/jar/JarMojo.java test/java/org/apache/maven/plugins/jar/JarMojoTest.java Date: Fri, 18 Dec 2015 17:40:22 -0000 To: commits@maven.apache.org From: khmarbaise@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151218174022.438023A019A@svn01-us-west.apache.org> Author: khmarbaise Date: Fri Dec 18 17:40:21 2015 New Revision: 1720830 URL: http://svn.apache.org/viewvc?rev=1720830&view=rev Log: [MJAR-177] Empty string should be treated as default classifier - The classifier will now correctly being checked against null and to contain more than white spaces. The default value for the classifier empty string has been removed. Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/JarMojo.java maven/plugins/trunk/maven-jar-plugin/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java?rev=1720830&r1=1720829&r2=1720830&view=diff ============================================================================== --- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java (original) +++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java Fri Dec 18 17:40:21 2015 @@ -43,9 +43,9 @@ public abstract class AbstractJarMojo extends AbstractMojo { - private static final String[] DEFAULT_EXCLUDES = new String[]{ "**/package.html" }; + private static final String[] DEFAULT_EXCLUDES = new String[] { "**/package.html" }; - private static final String[] DEFAULT_INCLUDES = new String[]{ "**/**" }; + private static final String[] DEFAULT_INCLUDES = new String[] { "**/**" }; /** * List of files to include. Specified as fileset patterns which are relative to the input directory whose contents @@ -80,32 +80,33 @@ public abstract class AbstractJarMojo private JarArchiver jarArchiver; /** - * The Maven project. + * The {@link {MavenProject}. */ @Parameter( defaultValue = "${project}", readonly = true, required = true ) private MavenProject project; /** - * + * The {@link MavenSession}. */ @Parameter( defaultValue = "${session}", readonly = true, required = true ) private MavenSession session; /** - * The archive configuration to use. - * See Maven Archiver Reference. + * The archive configuration to use. See Maven + * Archiver Reference. */ @Parameter private MavenArchiveConfiguration archive = new MavenArchiveConfiguration(); /** - * Path to the default MANIFEST file to use. It will be used if - * useDefaultManifestFile is set to true. + * Path to the default MANIFEST file to use. It will be used if useDefaultManifestFile is set to + * true. * * @since 2.2 */ - @Parameter( defaultValue = "${project.build.outputDirectory}/META-INF/MANIFEST.MF", required = true, - readonly = true ) + // CHECKSTYLE_OFF: LineLength + @Parameter( defaultValue = "${project.build.outputDirectory}/META-INF/MANIFEST.MF", required = true, readonly = true ) + // CHECKSTYLE_ON: LineLength private File defaultManifestFile; /** @@ -123,14 +124,13 @@ public abstract class AbstractJarMojo private MavenProjectHelper projectHelper; /** - * Require the jar plugin to build a new JAR even if none of the contents appear to have changed. - * By default, this plugin looks to see if the output jar exists and inputs have not changed. - * If these conditions are true, the plugin skips creation of the jar. This does not work when - * other plugins, like the maven-shade-plugin, are configured to post-process the jar. - * This plugin can not detect the post-processing, and so leaves the post-processed jar in place. - * This can lead to failures when those plugins do not expect to find their own output - * as an input. Set this parameter to true to avoid these problems by forcing - * this plugin to recreate the jar every time. + * Require the jar plugin to build a new JAR even if none of the contents appear to have changed. By default, this + * plugin looks to see if the output jar exists and inputs have not changed. If these conditions are true, the + * plugin skips creation of the jar. This does not work when other plugins, like the maven-shade-plugin, are + * configured to post-process the jar. This plugin can not detect the post-processing, and so leaves the + * post-processed jar in place. This can lead to failures when those plugins do not expect to find their own output + * as an input. Set this parameter to true to avoid these problems by forcing this plugin to recreate the + * jar every time. */ @Parameter( property = "jar.forceCreation", defaultValue = "false" ) private boolean forceCreation; @@ -176,15 +176,13 @@ public abstract class AbstractJarMojo } /** - * Default Manifest location. Can point to a non existing file. - * Cannot return null. + * Default Manifest location. Can point to a non existing file. Cannot return null. */ protected File getDefaultManifestFile() { return defaultManifestFile; } - /** * Generates the JAR. * @@ -250,10 +248,9 @@ public abstract class AbstractJarMojo { File jarFile = createArchive(); - String classifier = getClassifier(); - if ( classifier != null ) + if ( hasClassifier() ) { - projectHelper.attachArtifact( getProject(), getType(), classifier, jarFile ); + projectHelper.attachArtifact( getProject(), getType(), getClassifier(), jarFile ); } else { @@ -262,6 +259,20 @@ public abstract class AbstractJarMojo } } + /** + * @return true in case where the classifier is not {@code null} and contains something else than white spaces. + */ + private boolean hasClassifier() + { + boolean result = false; + if ( getClassifier() != null && getClassifier().trim().length() > 0 ) + { + result = true; + } + + return result; + } + private String[] getIncludes() { if ( includes != null && includes.length > 0 ) Modified: maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/JarMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/JarMojo.java?rev=1720830&r1=1720829&r2=1720830&view=diff ============================================================================== --- maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/JarMojo.java (original) +++ maven/plugins/trunk/maven-jar-plugin/src/main/java/org/apache/maven/plugins/jar/JarMojo.java Fri Dec 18 17:40:21 2015 @@ -48,7 +48,7 @@ public class JarMojo * If this is not given,it will merely be written to the output directory * according to the finalName. */ - @Parameter( property = "maven.jar.classifier", defaultValue = "" ) + @Parameter( property = "maven.jar.classifier" ) private String classifier; protected String getClassifier() Modified: maven/plugins/trunk/maven-jar-plugin/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java?rev=1720830&r1=1720829&r2=1720830&view=diff ============================================================================== --- maven/plugins/trunk/maven-jar-plugin/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java (original) +++ maven/plugins/trunk/maven-jar-plugin/src/test/java/org/apache/maven/plugins/jar/JarMojoTest.java Fri Dec 18 17:40:21 2015 @@ -52,7 +52,7 @@ public class JarMojoTest throws Exception { - //File pom = new File( getBasedir(), "src/test/resources/unit/clean/pom.xml" ); + // File pom = new File( getBasedir(), "src/test/resources/unit/clean/pom.xml" ); JarMojo mojo = (JarMojo) lookupMojo( "jar", testPom );