You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@locus.apache.org on 2000/12/10 09:30:54 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs SignJar.java
donaldp 00/12/10 00:30:53
Modified: src/main/org/apache/tools/ant/taskdefs SignJar.java
Log:
Adapted Signjar so that it does not run every time unless absolutely required (or unable to be determined if required).
Submitted By: keeskuip@technologist.com
Revision Changes Path
1.6 +21 -2 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SignJar.java 2000/11/25 01:10:07 1.5
+++ SignJar.java 2000/12/10 08:30:53 1.6
@@ -60,7 +60,7 @@
/**
* Sign a archive.
*
- * @author Peter Donald <a href="mailto:donaldp@mad.scientist.com">donaldp@mad.scientist.com</a>
+ * @author Peter Donald <a href="mailto:donaldp@apache.org">donaldp@apache.org</a>
*/
public class SignJar extends Task {
@@ -148,6 +148,8 @@
throw new BuildException("storepass attribute must be set");
}
+ if(isUpToDate()) return;
+
final StringBuffer sb = new StringBuffer();
final ExecTask cmd = (ExecTask) project.createTask("exec");
@@ -204,6 +206,23 @@
cmd.setFailonerror(true);
cmd.setTaskName( getTaskName() );
cmd.execute();
- }
+ }
+
+ protected boolean isUpToDate() {
+
+ if( null != jar && null != signedjar ) {
+
+ final File jarFile = new File(jar);
+ final File signedjarFile = new File(signedjar);
+
+ if(!jarFile.exists()) return false;
+ if(!signedjarFile.exists()) return false;
+ if(jarFile.equals(signedjarFile)) return false;
+ if(signedjarFile.lastModified() > jarFile.lastModified())
+ return true;
+ }
+
+ return false;
+ }
}