diff --git a/WHATSNEW b/WHATSNEW index 608527474..6cd11da77 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -28,6 +28,10 @@ Other changes: and -providerArg command line options of keytool via new attributes. Bugzilla Report 65234 + * signjar and verifyjar now supported nested elements for + command line arguments that are not supported explicitly by the + tasks via attributes. + Changes from Ant 1.9.12 TO Ant 1.9.13 ===================================== diff --git a/manual/Tasks/signjar.html b/manual/Tasks/signjar.html index f6a7a376a..88bdb4380 100644 --- a/manual/Tasks/signjar.html +++ b/manual/Tasks/signjar.html @@ -238,7 +238,15 @@ block environment variables No, and only one can be supplied - + + arg + Use this to specify a keytool + command line argument not + explicitly supported via an attribute. + since Ant 1.9.14. + No + +

Examples

diff --git a/manual/Tasks/verifyjar.html b/manual/Tasks/verifyjar.html index bf442b728..b2df42623 100644 --- a/manual/Tasks/verifyjar.html +++ b/manual/Tasks/verifyjar.html @@ -152,7 +152,15 @@ supported environment variables No, and only one can be supplied - + + arg + Use this to specify a keytool + command line argument not + explicitly supported via an attribute. + since Ant 1.9.14. + No + +

Examples

diff --git a/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java b/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java index b15d2bc9f..b81179728 100644 --- a/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/AbstractJarSignerTask.java @@ -19,11 +19,14 @@ package org.apache.tools.ant.taskdefs; import java.io.File; +import java.util.ArrayList; +import java.util.List; import java.util.Vector; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; import org.apache.tools.ant.filters.LineContainsRegExp; +import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Environment; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; @@ -123,6 +126,8 @@ public abstract class AbstractJarSignerTask extends Task { */ private String providerName, providerClass, providerArg; + private List additionalArgs = new ArrayList(); + /** * Set the maximum memory to be used by the jarsigner process * @@ -270,6 +275,16 @@ public abstract class AbstractJarSignerTask extends Task { this.providerArg = providerArg; } + /** + * Adds a nested <arg> element that can be used to specify + * command line arguments not supported via specific attributes. + * + * @since Ant 1.9.14 + */ + public void addArg(Commandline.Argument arg) { + additionalArgs.add(arg); + } + /** * init processing logic; this is retained through our execution(s) */ @@ -351,6 +366,10 @@ public abstract class AbstractJarSignerTask extends Task { for (Environment.Variable variable : sysProperties.getVariablesVector()) { declareSysProperty(cmd, variable); } + + for (Commandline.Argument arg : additionalArgs) { + addArgument(cmd, arg); + } } /** @@ -473,4 +492,13 @@ public abstract class AbstractJarSignerTask extends Task { protected void addValue(final ExecTask cmd, String value) { cmd.createArg().setValue(value); } + + /** + * add an argument to a command + * @param cmd command to manipulate + * @param arg argument to add + */ + protected void addArgument(final ExecTask cmd, Commandline.Argument arg) { + cmd.createArg().copyFrom(arg); + } } diff --git a/src/main/org/apache/tools/ant/types/Commandline.java b/src/main/org/apache/tools/ant/types/Commandline.java index a1859ba79..77d953b24 100644 --- a/src/main/org/apache/tools/ant/types/Commandline.java +++ b/src/main/org/apache/tools/ant/types/Commandline.java @@ -182,6 +182,17 @@ public class Commandline implements Cloneable { this.suffix = suffix != null ? suffix : ""; } + /** + * Copies settings from a different argument. + * + * @since Ant 1.9.14 + */ + public void copyFrom(Argument other) { + this.parts = other.parts; + this.prefix = other.prefix; + this.suffix = other.suffix; + } + /** * Return the constituent parts of this Argument. * @return an array of strings.