From 90c28ffdf98130bfe0c147e5485b60a77dfac02b Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Thu, 10 Feb 2005 22:48:46 +0000 Subject: [PATCH] Move some validation into execute(); remove unnecessary guards against storepass == null. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277630 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/SignJar.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/SignJar.java b/src/main/org/apache/tools/ant/taskdefs/SignJar.java index dcddb5600..5deb4718d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SignJar.java +++ b/src/main/org/apache/tools/ant/taskdefs/SignJar.java @@ -214,6 +214,13 @@ public class SignJar extends Task { throw new BuildException("jar must be set through jar attribute " + "or nested filesets"); } + if (null == alias) { + throw new BuildException("alias attribute must be set"); + } + + if (null == storepass) { + throw new BuildException("storepass attribute must be set"); + } redirector = createRedirector(); if (null != jar) { if (filesets.size() != 0) { @@ -241,14 +248,8 @@ public class SignJar extends Task { * @return a configured RedirectorElement. */ private RedirectorElement createRedirector() { - if (storepass == null && keypass == null) { - return null; - } RedirectorElement result = new RedirectorElement(); - StringBuffer input = new StringBuffer(); - if (storepass != null) { - input.append(storepass).append('\n'); - } + StringBuffer input = new StringBuffer(storepass).append('\n'); if (keypass != null) { input.append(keypass).append('\n'); } @@ -263,14 +264,6 @@ public class SignJar extends Task { private void doOneJar(File jarSource, File jarTarget) throws BuildException { - if (null == alias) { - throw new BuildException("alias attribute must be set"); - } - - if (null == storepass) { - throw new BuildException("storepass attribute must be set"); - } - if (isUpToDate(jarSource, jarTarget)) { return; } @@ -329,9 +322,7 @@ public class SignJar extends Task { log("Signing JAR: " + jarSource.getAbsolutePath()); cmd.setFailonerror(true); cmd.setTaskName(getTaskName()); - if (redirector != null) { - cmd.addConfiguredRedirector(redirector); - } + cmd.addConfiguredRedirector(redirector); cmd.execute(); // restore the lastModified attribute