Return-Path: X-Original-To: apmail-ant-notifications-archive@minotaur.apache.org Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C5EBE9FEF for ; Tue, 11 Oct 2011 16:22:05 +0000 (UTC) Received: (qmail 26128 invoked by uid 500); 11 Oct 2011 16:22:05 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 26097 invoked by uid 500); 11 Oct 2011 16:22:05 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 26090 invoked by uid 99); 11 Oct 2011 16:22:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 16:22:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 16:22:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DAD8023889D7 for ; Tue, 11 Oct 2011 16:21:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1181872 - in /ant/antlibs/compress/trunk/src: main/org/apache/ant/compress/antlib.xml main/org/apache/ant/compress/taskdefs/Pack200Normalize.java tests/antunit/pack200normalize-test.xml Date: Tue, 11 Oct 2011 16:21:43 -0000 To: notifications@ant.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111011162143.DAD8023889D7@eris.apache.org> Author: bodewig Date: Tue Oct 11 16:21:43 2011 New Revision: 1181872 URL: http://svn.apache.org/viewvc?rev=1181872&view=rev Log: task that 'normalizes' jars for use with pack200 Added: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java (with props) ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml (with props) Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml?rev=1181872&r1=1181871&r2=1181872&view=diff ============================================================================== --- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml (original) +++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml Tue Oct 11 16:21:43 2011 @@ -76,6 +76,10 @@ name="pack200" classname="org.apache.ant.compress.taskdefs.Pack200" /> + As stated in Pack200.Packer's + * javadocs applying a Pack200 compression to a JAR archive will in + * general make its sigantures invalid. In order to prepare a JAR for + * signing it should be "normalized" by packing and unpacking it. + * This is what this task does.

+ * @since Apache Compress Antlib 1.1 + */ +public class Pack200Normalize extends Task { + private File src, dest; + private boolean force = false; + private Map/**/ properties = new HashMap(); + + /** + * The JAR archive to normalize. + */ + public void setSrcFile(File s) { + src = s; + } + + /** + * The destination archive. + */ + public void setDestFile(File d) { + dest = d; + } + + /** + * Whether to force normalization of the archive even if the + * destination is up-to-date. + * + *

You must set this to true if you don't specify a destFile or + * the archive will never get normalized.

+ */ + public void setForce(boolean b) { + force = b; + } + + /** + * Sets a property for the Pack200 packer. + */ + public void addConfiguredProperty(Environment.Variable prop) { + prop.validate(); + properties.put(prop.getKey(), prop.getValue()); + } + + public void execute() { + if (src == null) { + throw new BuildException("srcFile attribute is required"); + } + if (force || + (dest != null && dest.lastModified() <= src.lastModified())) { + if (dest != null) { + log("Normalizing " + src + " to " + dest + "."); + } else { + log("Normalizing " + src + "."); + } + try { + Pack200Utils.normalize(src, dest, properties); + } catch (IOException ex) { + throw new BuildException("Caught an error normalizing " + + src, ex); + } + } else if (dest != null) { + log(src + " not normalized as " + dest + " is up-to-date.", + Project.MSG_VERBOSE); + } else { + log(src + " not normalized as force attribute is false.", + Project.MSG_VERBOSE); + } + } +} \ No newline at end of file Propchange: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Pack200Normalize.java ------------------------------------------------------------------------------ svn:eol-style = native Added: ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml?rev=1181872&view=auto ============================================================================== --- ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml (added) +++ ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml Tue Oct 11 16:21:43 2011 @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: ant/antlibs/compress/trunk/src/tests/antunit/pack200normalize-test.xml ------------------------------------------------------------------------------ svn:eol-style = native