PR: 18876 At the same time fix the broken "do I have fileset child elements" check and warn users if nested filesets are ignored. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274427 13f79535-47bb-0310-9956-ffa450edef68master
@@ -14,8 +14,7 @@ tool detailed dependency checking: files are only signed if they | |||||
are not signed. The <tt>signjar</tt> attribute can point to the file to | are not signed. The <tt>signjar</tt> attribute can point to the file to | ||||
generate; if this file exists then | generate; if this file exists then | ||||
its modification date is used as a cue as to whether to resign any JAR file. | its modification date is used as a cue as to whether to resign any JAR file. | ||||
<br> | |||||
<strong>Note:</strong> Requires Java 1.2 or later. </p> | |||||
</p> | |||||
<h3>Parameters</h3> | <h3>Parameters</h3> | ||||
<table border="1" cellpadding="2" cellspacing="0"> | <table border="1" cellpadding="2" cellspacing="0"> | ||||
@@ -27,7 +26,8 @@ its modification date is used as a cue as to whether to resign any JAR file. | |||||
<tr> | <tr> | ||||
<td valign="top">jar</td> | <td valign="top">jar</td> | ||||
<td valign="top">the jar file to sign</td> | <td valign="top">the jar file to sign</td> | ||||
<td valign="top" align="center">Yes.</td> | |||||
<td valign="top" align="center">Yes, unless nested filesets have | |||||
been used.</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td valign="top">alias</td> | <td valign="top">alias</td> | ||||
@@ -102,7 +102,8 @@ block</td> | |||||
</tr> | </tr> | ||||
<tr> | <tr> | ||||
<td valign="top">fileset</td> | <td valign="top">fileset</td> | ||||
<td valign="top">fileset of JAR files to sign</td> | |||||
<td valign="top">fileset of JAR files to sign. Will be ignored if | |||||
the jar attribute of the task has been set.</td> | |||||
<td valign="top" align="center">No</td> | <td valign="top" align="center">No</td> | ||||
</tr> | </tr> | ||||
</table> | </table> | ||||
@@ -114,7 +115,7 @@ alias="apache-group" storepass="secret"/></code></p> | |||||
<p>signs the ant.jar with alias "apache-group" accessing the | <p>signs the ant.jar with alias "apache-group" accessing the | ||||
keystore and private key via "secret" password.</p> | keystore and private key via "secret" password.</p> | ||||
<hr> | <hr> | ||||
<p align="center">Copyright © 2000-2002 Apache Software Foundation. All rights | |||||
<p align="center">Copyright © 2000-2003 Apache Software Foundation. All rights | |||||
Reserved.</p> | Reserved.</p> | ||||
</body> | </body> | ||||
@@ -61,6 +61,7 @@ import java.util.zip.ZipEntry; | |||||
import java.util.zip.ZipFile; | import java.util.zip.ZipFile; | ||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.DirectoryScanner; | import org.apache.tools.ant.DirectoryScanner; | ||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
import org.apache.tools.ant.util.JavaEnvUtils; | import org.apache.tools.ant.util.JavaEnvUtils; | ||||
@@ -235,16 +236,19 @@ public class SignJar extends Task { | |||||
* sign the jar(s) | * sign the jar(s) | ||||
*/ | */ | ||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
if (null == jar && null == filesets) { | |||||
if (null == jar && filesets.size() == 0) { | |||||
throw new BuildException("jar must be set through jar attribute " | throw new BuildException("jar must be set through jar attribute " | ||||
+ "or nested filesets"); | + "or nested filesets"); | ||||
} | } | ||||
if (null != jar) { | if (null != jar) { | ||||
if (filesets.size() != 0) { | |||||
log("nested filesets will be ignored if the jar attribute has" | |||||
+ " been specified.", Project.MSG_WARN); | |||||
} | |||||
doOneJar(jar, signedjar); | doOneJar(jar, signedjar); | ||||
return; | return; | ||||
} else { | } else { | ||||
//Assume null != filesets | |||||
// deal with the filesets | // deal with the filesets | ||||
for (int i = 0; i < filesets.size(); i++) { | for (int i = 0; i < filesets.size(); i++) { | ||||
FileSet fs = (FileSet) filesets.elementAt(i); | FileSet fs = (FileSet) filesets.elementAt(i); | ||||
@@ -262,10 +266,6 @@ public class SignJar extends Task { | |||||
*/ | */ | ||||
private void doOneJar(File jarSource, File jarTarget) | private void doOneJar(File jarSource, File jarTarget) | ||||
throws BuildException { | throws BuildException { | ||||
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { | |||||
throw new BuildException("The signjar task is only available on " | |||||
+ "JDK versions 1.2 or greater"); | |||||
} | |||||
if (null == alias) { | if (null == alias) { | ||||
throw new BuildException("alias attribute must be set"); | throw new BuildException("alias attribute must be set"); | ||||
@@ -276,7 +276,7 @@ public class SignJar extends Task { | |||||
} | } | ||||
if (isUpToDate(jarSource, jarTarget)) { | if (isUpToDate(jarSource, jarTarget)) { | ||||
return; | |||||
return; | |||||
} | } | ||||
final ExecTask cmd = (ExecTask) getProject().createTask("exec"); | final ExecTask cmd = (ExecTask) getProject().createTask("exec"); | ||||