From 0cda41d5b7cff73ed4acfd6a4600a843af25b5db Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 9 Apr 2009 14:17:38 +0000 Subject: [PATCH] add a force option to signjar. Based on submission by Pavel Jisl. PR 46891 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@763661 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++++ contributors.xml | 4 ++++ docs/manual/CoreTasks/signjar.html | 8 ++++++- .../apache/tools/ant/taskdefs/SignJar.java | 24 ++++++++++++++++++- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index b68a0359e..ee3c9d955 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -363,6 +363,10 @@ Fixed bugs: * The ant shell script should now support MSYS/MinGW as well. Bugzilla Report 46936. + * has a new force attribute that allows re-signing of jars + that are already signed. + Bugzilla Report 46891. + Other changes: -------------- * A HostInfo task was added performing information on hosts, including info on diff --git a/contributors.xml b/contributors.xml index 71228e495..4304d8b8d 100644 --- a/contributors.xml +++ b/contributors.xml @@ -927,6 +927,10 @@ Paulo Gaspar + + Pavel + Jisl + Paweł Zuzelski diff --git a/docs/manual/CoreTasks/signjar.html b/docs/manual/CoreTasks/signjar.html index 8bf0147f3..c9aedf748 100644 --- a/docs/manual/CoreTasks/signjar.html +++ b/docs/manual/CoreTasks/signjar.html @@ -149,9 +149,15 @@ block Must support the same command line options as the Sun JDK jarsigner command. since Ant 1.8.0. - all No + + force + Whether to force signing of the jar file even if + it doesn't seem to be out of date or already signed. + since Ant 1.8.0. + No; default false +

Parameters as nested elements

diff --git a/src/main/org/apache/tools/ant/taskdefs/SignJar.java b/src/main/org/apache/tools/ant/taskdefs/SignJar.java index 9a6c671fa..40038eb8a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SignJar.java +++ b/src/main/org/apache/tools/ant/taskdefs/SignJar.java @@ -104,6 +104,11 @@ public class SignJar extends AbstractJarSignerTask { */ protected String tsacert; + /** + * force signing even if the jar is already signed. + */ + private boolean force = false; + /** * error string for unit test verification: {@value} */ @@ -253,6 +258,23 @@ public class SignJar extends AbstractJarSignerTask { this.tsacert = tsacert; } + /** + * Whether to force signing of a jar even it is already signed. + * @since Ant 1.8.0 + */ + public void setForce(boolean b) { + force = b; + } + + /** + * Should the task force signing of a jar even it is already + * signed? + * @since Ant 1.8.0 + */ + public boolean isForce() { + return force; + } + /** * sign the jar(s) * @@ -448,7 +470,7 @@ public class SignJar extends AbstractJarSignerTask { * @return true if the signedjarFile is considered up to date */ protected boolean isUpToDate(File jarFile, File signedjarFile) { - if (null == jarFile || !jarFile.exists()) { + if (isForce() || null == jarFile || !jarFile.exists()) { //these are pathological cases, but retained in case somebody //subclassed us. return false;