ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/etc/testcases/taskdefs signjar.xml
Date Fri, 26 Nov 2004 09:52:06 GMT
peterreilly    2004/11/26 01:52:06

  Modified:    .        WHATSNEW CONTRIBUTORS
               docs/manual/CoreTasks signjar.html
               src/main/org/apache/tools/ant/taskdefs SignJar.java
               src/testcases/org/apache/tools/ant/taskdefs SignJarTest.java
               src/etc/testcases/taskdefs signjar.xml
  Log:
  add new preservelastmodified attribute to signjar
  PR: 30987
  Obtained from: Ignacio Coloma
  
  Revision  Changes    Path
  1.688     +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.687
  retrieving revision 1.688
  diff -u -r1.687 -r1.688
  --- WHATSNEW	22 Nov 2004 10:07:22 -0000	1.687
  +++ WHATSNEW	26 Nov 2004 09:52:05 -0000	1.688
  @@ -92,6 +92,9 @@
   * Added isSigned condition and task, and signedselector selector
     Bugzilla report 32126.
   
  +* Added preserveLastModified attribute to signjar task.
  +  Bugzilla report 30987.
  +
   Changes from Ant 1.6.2 to current Ant 1.6 CVS version
   =====================================================
   
  
  
  
  1.40      +1 -0      ant/CONTRIBUTORS
  
  Index: CONTRIBUTORS
  ===================================================================
  RCS file: /home/cvs/ant/CONTRIBUTORS,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- CONTRIBUTORS	19 Nov 2004 09:07:08 -0000	1.39
  +++ CONTRIBUTORS	26 Nov 2004 09:52:05 -0000	1.40
  @@ -74,6 +74,7 @@
   Haroon Rafique
   Hiroaki Nakamura
   Holger Engels
  +Ignacio Coloma
   Ingenonsya France
   Ingmar Stein
   Irene Rusman
  
  
  
  1.12      +6 -0      ant/docs/manual/CoreTasks/signjar.html
  
  Index: signjar.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/signjar.html,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- signjar.html	9 Feb 2004 21:50:05 -0000	1.11
  +++ signjar.html	26 Nov 2004 09:52:06 -0000	1.12
  @@ -92,6 +92,12 @@
                        style of standard java memory specs (e.g. 128m = 128 MBytes)</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">preservelastmodified</td>
  +    <td valign="top">Give the signed file the same last modified
  +      time as the original jar file.</td>
  +    <td valign="top" align="center">No; default false.</td>
  +  </tr>
   </table>
   <h3>Parameters as nested elements</h3>
   <table border="1" cellpadding="2" cellspacing="0">
  
  
  
  1.40      +20 -0     ant/src/main/org/apache/tools/ant/taskdefs/SignJar.java
  
  Index: SignJar.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/SignJar.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- SignJar.java	22 Nov 2004 11:42:53 -0000	1.39
  +++ SignJar.java	26 Nov 2004 09:52:06 -0000	1.40
  @@ -66,6 +66,7 @@
       protected boolean verbose;
       protected boolean internalsf;
       protected boolean sectionsonly;
  +    protected boolean preserveLastModified;
   
       /** The maximum amount of memory to use for Jar signer */
       private String maxMemory;
  @@ -237,6 +238,7 @@
               return;
           }
   
  +        long lastModified = jarSource.lastModified();
           final ExecTask cmd = (ExecTask) getProject().createTask("exec");
           cmd.setExecutable(JavaEnvUtils.getJdkExecutable("jarsigner"));
   
  @@ -302,6 +304,15 @@
           cmd.setFailonerror(true);
           cmd.setTaskName(getTaskName());
           cmd.execute();
  +
  +        // restore the lastModified attribute
  +        if (preserveLastModified) {
  +            if (jarTarget != null) {
  +                jarTarget.setLastModified(lastModified);
  +            } else {
  +                jarSource.setLastModified(lastModified);
  +            }
  +        }
       }
   
       protected boolean isUpToDate(File jarFile, File signedjarFile) {
  @@ -344,6 +355,15 @@
           } catch (IOException e) {
               return false;
           }
  +    }
  +
  +    /**
  +     * true to indicate that the signed jar modification date remains the same as the original.
  +     * Defaults to false
  +     * @param preserveLastModified if true preserve the last modified time
  +     */
  +    public void setPreserveLastModified(boolean preserveLastModified) {
  +        this.preserveLastModified = preserveLastModified;
       }
   }
   
  
  
  
  1.9       +4 -0      ant/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java
  
  Index: SignJarTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SignJarTest.java	9 Mar 2004 16:48:57 -0000	1.8
  +++ SignJarTest.java	26 Nov 2004 09:52:06 -0000	1.9
  @@ -66,4 +66,8 @@
       public void testURLKeystoreHTTP() {
           executeTarget("urlKeystoreHTTP");
       }
  +
  +    public void testPreserveLastModified() {
  +        executeTarget("preserveLastModified");
  +    }
   }
  
  
  
  1.4       +26 -0     ant/src/etc/testcases/taskdefs/signjar.xml
  
  Index: signjar.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/signjar.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- signjar.xml	11 Feb 2003 04:44:36 -0000	1.3
  +++ signjar.xml	26 Nov 2004 09:52:06 -0000	1.4
  @@ -32,6 +32,32 @@
                storepass="apacheant" maxmemory="128m"/>
     </target>
   
  +  <target name="preserveLastModified">
  +    <jar jarfile="signtest.jar" basedir="${classes.dir}" includes="**/Task.class"/>
  +    <touch file="signtest.jar" datetime="06/28/2000 2:02 pm"/>
  +    <signjar jar="signtest.jar" alias="testonly" keystore="testkeystore" storepass="apacheant"

  +    	preservelastmodified="true"/>
  +    <!-- Currently there is no condition for testing the date of file - so
  +         use a selector -->
  +    <pathconvert property="signtest.jar.prop" targetos="unix">
  +      <path>
  +        <fileset dir="." includes="signtest.jar">
  +          <date datetime="06/28/2000 2:02 pm" when="equal"/>
  +        </fileset>
  +      </path>
  +      <mapper>
  +        <flattenmapper/>
  +      </mapper>
  +    </pathconvert>
  +    <fail message="preserveLastModified did not preserve the last modified time">
  +      <condition>
  +        <not>
  +          <equals arg1="signtest.jar" arg2="signtest.jar"/>
  +        </not>
  +      </condition>
  +    </fail>
  +  </target>
  +
     <target name="clean">
       <delete file="signtest.jar"/>
     </target>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message