ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Touch.java
Date Mon, 19 Mar 2001 13:05:45 GMT
bodewig     01/03/19 05:05:45

  Modified:    src/main/org/apache/tools/ant Project.java
               src/main/org/apache/tools/ant/taskdefs Touch.java
  Log:
  Centralize method for setting last modification time of a file in Project.
  
  Submitted by:	Steve Loughran <steve_l@iseran.com>
  
  Revision  Changes    Path
  1.56      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- Project.java	2001/03/13 14:15:21	1.55
  +++ Project.java	2001/03/19 13:05:45	1.56
  @@ -803,7 +803,7 @@
       /**
        * Calls File.setLastModified(long time) in a Java 1.1 compatible way.
        */
  -    void setFileLastModified(File file, long time) throws BuildException {
  +    public void setFileLastModified(File file, long time) throws BuildException {
           if (getJavaVersion() == JAVA_1_1) {
               log("Cannot change the modification time of " + file
                   + " in JDK 1.1", Project.MSG_WARN);
  
  
  
  1.6       +2 -35     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Touch.java
  
  Index: Touch.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Touch.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Touch.java	2001/01/03 14:18:31	1.5
  +++ Touch.java	2001/03/19 13:05:45	1.6
  @@ -81,9 +81,6 @@
       private long millis = -1;
       private String dateTime;
   
  -    private static Method setLastModified = null;
  -    private static Object lockReflection = new Object();
  -
       /**
        * The name of the file to touch.
        */
  @@ -157,40 +154,10 @@
               return;
           }
   
  -        if (setLastModified == null) {
  -            synchronized (lockReflection) {
  -                if (setLastModified == null) {
  -                    try {
  -                        setLastModified = 
  -                            java.io.File.class.getMethod("setLastModified", 
  -                                                         new Class[] {Long.TYPE});
  -                    } catch (NoSuchMethodException nse) {
  -                        throw new BuildException("File.setlastModified not in JDK >
1.1?",
  -                                                 nse, location);
  -                    }
  -                }
  -            }
  -        }
  -        
  -        Long[] times = new Long[1];
           if (millis < 0) {
  -            times[0] = new Long(System.currentTimeMillis());
  +            project.setFileLastModified(file, System.currentTimeMillis());
           } else {
  -            times[0] = new Long(millis);
  -        }
  -
  -        try {
  -            log("Setting modification time for "+file, 
  -                Project.MSG_VERBOSE);
  -
  -            setLastModified.invoke(file, times);
  -        } catch (InvocationTargetException ite) {
  -            Throwable nested = ite.getTargetException();
  -            throw new BuildException("Exception setting the modification time of "
  -                                     + file, nested, location);
  -        } catch (Throwable other) {
  -            throw new BuildException("Exception setting the modification time of "
  -                                     + file, other, location);
  +            project.setFileLastModified(file, millis);
           }
       }
   
  
  
  

Mime
View raw message