ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject cvs commit: ant/src/etc/testcases/taskdefs/fixcrlf build.xml
Date Thu, 03 Mar 2005 16:24:27 GMT
mbenson     2005/03/03 08:24:26

  Modified:    src/main/org/apache/tools/ant/taskdefs FixCRLF.java
               src/testcases/org/apache/tools/ant/taskdefs FixCrLfTest.java
               docs/manual/CoreTasks fixcrlf.html
               .        WHATSNEW
               src/etc/testcases/taskdefs/fixcrlf build.xml
  Log:
  Add preservelastmodified attribute to fixcrlf.
  PR: 25770
  Submitted by: Yuji Yamano
  
  Revision  Changes    Path
  1.65      +15 -1     ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
  
  Index: FixCRLF.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- FixCRLF.java	25 Feb 2005 00:33:00 -0000	1.64
  +++ FixCRLF.java	3 Mar 2005 16:24:26 -0000	1.65
  @@ -118,6 +118,7 @@
       private int tabs;
       private boolean javafiles = false;
       private boolean fixlast = true;
  +    private boolean preserveLastModified = false;
   
       private File srcDir;
       private File destDir = null;
  @@ -319,6 +320,14 @@
       }
   
       /**
  +     * Set to true if keeping the last modified time as the original files.
  +     * @since Ant 1.6.3
  +     */
  +    public void setPreserveLastModified(boolean preserve) {
  +        preserveLastModified = preserve;
  +    }
  +
  +    /**
        * Executes the task.
        */
       public void execute() throws BuildException {
  @@ -381,6 +390,7 @@
   
       private void processFile(String file) throws BuildException {
           File srcFile = new File(srcDir, file);
  +        long lastModified = srcFile.lastModified();
           File destD = destDir == null ? srcDir : destDir;
           File tmpFile = null;
           BufferedWriter outWriter;
  @@ -557,6 +567,10 @@
   
               if (destIsWrong) {
                   FILE_UTILS.rename(tmpFile, destFile);
  +                if (preserveLastModified) {
  +                    log("preserved lastModified", Project.MSG_DEBUG);
  +                    FILE_UTILS.setFileLastModified(destFile, lastModified);
  +                }
                   tmpFile = null;
               }
   
  
  
  
  1.24      +5 -1      ant/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java
  
  Index: FixCrLfTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- FixCrLfTest.java	25 Feb 2005 00:33:00 -0000	1.23
  +++ FixCrLfTest.java	3 Mar 2005 16:24:26 -0000	1.24
  @@ -1,5 +1,5 @@
   /*
  - * Copyright  2001-2004 The Apache Software Foundation
  + * Copyright  2001-2005 The Apache Software Foundation
    *
    *  Licensed under the Apache License, Version 2.0 (the "License");
    *  you may not use this file except in compliance with the License.
  @@ -197,6 +197,10 @@
           executeTarget("createParentDirs");
       }
   
  +    public void testPreserveLastModified() {
  +        executeTarget("testPreserveLastModified");
  +    }
  +
       public void assertEqualContent(File expect, File result)
           throws AssertionFailedError, IOException {
           if (!result.exists()) {
  
  
  
  1.18      +7 -1      ant/docs/manual/CoreTasks/fixcrlf.html
  
  Index: fixcrlf.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/fixcrlf.html,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- fixcrlf.html	25 Feb 2005 00:33:00 -0000	1.17
  +++ fixcrlf.html	3 Mar 2005 16:24:26 -0000	1.18
  @@ -231,6 +231,12 @@
                        of a processed file. (Since ant 1.6.1)</td>
       <td align="center">No - default is <i>true</i></td>
     </tr>
  +  <tr>
  +    <td valign="top">preservelastmodified</td>
  +    <td valign="top">Whether to preserve the last modified
  +                     date of source files. <b>Since ant 1.6.3</b></td>
  +    <td align="center">No; default is <i>false</i></td>
  +  </tr>
   </table>
   <h3>Examples</h3>
   <pre>  &lt;fixcrlf srcdir=&quot;${src}&quot;
  @@ -283,7 +289,7 @@
   DOS systems, and are removed if run on Unix systems.
   You never know what editor a user will use to browse README's.</p>
   <hr>
  -<p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation.
All rights
  +<p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation.
All rights
   Reserved.</p>
   
   </body>
  
  
  
  1.761     +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.760
  retrieving revision 1.761
  diff -u -r1.760 -r1.761
  --- WHATSNEW	1 Mar 2005 23:09:58 -0000	1.760
  +++ WHATSNEW	3 Mar 2005 16:24:26 -0000	1.761
  @@ -241,6 +241,8 @@
   * Pathconvert no longer requires that one of (targetos|pathsep|dirsep)
     be set; platform defaults are used when this is the case.
   
  +* Added preservelastmodified attribute to fixcrlf task. Bugzilla 25770.
  +
   Fixed bugs:
   -----------
   
  
  
  
  1.12      +24 -0     ant/src/etc/testcases/taskdefs/fixcrlf/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/fixcrlf/build.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- build.xml	25 Feb 2005 00:33:00 -0000	1.11
  +++ build.xml	3 Mar 2005 16:24:26 -0000	1.12
  @@ -170,4 +170,28 @@
       <fixcrlf file="input/longlines.crlf" srcdir="input" destdir="result"/>
     </target>
   
  +  <target name="testPreserveLastModified" depends="init">
  +    <fixcrlf file="input/longlines.crlf" destdir="result"
  +             preservelastmodified="true" />
  +    <fail>
  +      <condition>
  +        <not>
  +          <uptodate srcfile="result/longlines.crlf"
  +                    targetfile="input/longlines.crlf" />
  +        </not>
  +      </condition>
  +    </fail>
  +
  +    <touch file="result/longlines.crlf" millis="0" />
  +
  +    <fixcrlf file="result/longlines.crlf" destdir="result" eol="lf"
  +             preservelastmodified="true" />
  +
  +    <fileset id="fs" file="result/longlines.crlf">
  +      <date when="equal" millis="0" />
  +    </fileset>
  +    <property name="fs" refid="fs" />
  +    <fail unless="fs" />
  +  </target>
  +
   </project>
  
  
  

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


Mime
View raw message