conor 2002/12/23 05:29:16
Modified: docs/manual/CoreTasks signjar.html
src/main/org/apache/tools/ant/taskdefs SignJar.java
Added: src/etc/testcases testkeystore
src/etc/testcases/taskdefs signjar.xml
src/testcases/org/apache/tools/ant/taskdefs SignJarTest.java
Log:
Add maxmemory option to control memory of the jarsigner VM
revert sigfile to a String - does not make sense to be a File
Added a testcase with keystore for signjar
PR: 1284, 10754
Submitted by: Jonathan Keller
Revision Changes Path
1.8 +10 -4 jakarta-ant/docs/manual/CoreTasks/signjar.html
Index: signjar.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/signjar.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -u -r1.7 -r1.8
--- signjar.html 1 Jun 2002 12:26:33 -0000 1.7
+++ signjar.html 23 Dec 2002 13:29:16 -0000 1.8
@@ -86,6 +86,12 @@
file means a JAR is signed</td>
<td valign="top" align="center">No; default false</td>
</tr>
+ <tr>
+ <td valign="top">maxmemory</td>
+ <td valign="top">Specifies the maximum memory the jarsigner VM will use.
Specified in the
+ style of standard java memory specs (e.g. 128m = 128
MBytes)</td>
+ <td valign="top" align="center">No</td>
+ </tr>
</table>
<h3>Parameters as nested elements</h3>
<table border="1" cellpadding="2" cellspacing="0">
1.1 jakarta-ant/src/etc/testcases/testkeystore
<<Binary file>>
1.1 jakarta-ant/src/etc/testcases/taskdefs/signjar.xml
Index: signjar.xml
===================================================================
<project name="signjartest" default="help">
<property name="classes.dir" value="../../../../build/classes"/>
<target name="basic">
<jar jarfile="signtest.jar" basedir="${classes.dir}"
includes="**/Task.class"/>
<signjar jar="signtest.jar" alias="testonly" keystore="../testkeystore"
storepass="apacheant"/>
</target>
<target name="sigfile">
<jar jarfile="signtest.jar" basedir="${classes.dir}"
includes="**/Task.class"/>
<signjar jar="signtest.jar" alias="testonly" keystore="../testkeystore"
storepass="apacheant" sigfile="TEST"/>
</target>
<target name="maxmemory">
<jar jarfile="signtest.jar" basedir="${classes.dir}"
includes="**/Task.class"/>
<signjar jar="signtest.jar" alias="testonly" keystore="../testkeystore"
storepass="apacheant" maxmemory="128m"/>
</target>
<target name="clean">
<delete file="signtest.jar"/>
</target>
<target name="help">
<echo>This build is for use with Ant's test cases</echo>
</target>
</project>
1.25 +27 -9
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SignJar.java
Index: SignJar.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/SignJar.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -w -u -r1.24 -r1.25
--- SignJar.java 25 Jul 2002 15:21:05 -0000 1.24
+++ SignJar.java 23 Dec 2002 13:29:16 -0000 1.25
@@ -102,12 +102,15 @@
protected String storepass;
protected String storetype;
protected String keypass;
- protected File sigfile;
+ protected String sigfile;
protected File signedjar;
protected boolean verbose;
protected boolean internalsf;
protected boolean sectionsonly;
+ /** The maximum amount of memory to use for Jar signer */
+ private String maxMemory;
+
/**
* the filesets of the jars to sign
*/
@@ -118,6 +121,17 @@
*/
protected boolean lazy;
+
+ /**
+ * Set the maximum memory to be used by the jarsigner process
+ *
+ * @param max a string indicating the maximum memory according to the
+ * JVM conventions (e.g. 128m is 128 Megabytes)
+ */
+ public void setMaxmemory(String max) {
+ maxMemory = max;
+ }
+
/**
* the jar file to sign; required
*/
@@ -163,7 +177,7 @@
/**
* name of .SF/.DSA file; optional
*/
- public void setSigfile(final File sigfile) {
+ public void setSigfile(final String sigfile) {
this.sigfile = sigfile;
}
@@ -267,6 +281,10 @@
final ExecTask cmd = (ExecTask) getProject().createTask("exec");
cmd.setExecutable("jarsigner");
+ if (maxMemory != null) {
+ cmd.createArg().setValue("-J-Xmx" + maxMemory);
+ }
+
if (null != keystore) {
cmd.createArg().setValue("-keystore");
cmd.createArg().setValue(keystore.toString());
@@ -289,7 +307,7 @@
if (null != sigfile) {
cmd.createArg().setValue("-sigfile");
- cmd.createArg().setValue(sigfile.toString());
+ cmd.createArg().setValue(sigfile);
}
if (null != jarTarget) {
1.1
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java
Index: SignJarTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.taskdefs;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.Vector;
import java.util.Enumeration;
import org.apache.tools.ant.BuildFileTest;
import org.apache.tools.ant.Project;
/**
* Testcase for the Signjar task
*
* @author Conor MacNeill
*/
public class SignJarTest extends BuildFileTest {
public static final String EXPANDED_MANIFEST
= "src/etc/testcases/taskdefs/manifests/META-INF/MANIFEST.MF";
public SignJarTest(String name) {
super(name);
}
public void setUp() {
configureProject("src/etc/testcases/taskdefs/signjar.xml");
}
public void tearDown() {
executeTarget("clean");
}
public void testBasicSigning() {
executeTarget("basic");
}
public void testSigFile() {
executeTarget("sigfile");
}
public void testMaxMemory() {
executeTarget("maxmemory");
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>