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 ExecuteOn.java Expand.java Touch.java Tstamp.java Untar.java WaitFor.java
Date Fri, 12 Apr 2002 14:10:20 GMT
bodewig     02/04/12 07:10:20

  Modified:    src/main/org/apache/tools/ant/taskdefs ExecuteOn.java
                        Expand.java Touch.java Tstamp.java Untar.java
                        WaitFor.java
  Log:
  Make sure <touch> and <waitfor> reset their state.
  
  Revision  Changes    Path
  1.26      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  
  Index: ExecuteOn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ExecuteOn.java	12 Apr 2002 13:26:50 -0000	1.25
  +++ ExecuteOn.java	12 Apr 2002 14:10:19 -0000	1.26
  @@ -77,7 +77,7 @@
    *
    * @since Ant 1.2
    *
  - * @ant.task name="apply" category="control"
  + * @ant.task category="control" name="execon" name="apply"
    */
   public class ExecuteOn extends ExecTask {
   
  
  
  
  1.28      +11 -6     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java
  
  Index: Expand.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Expand.java	3 Mar 2002 01:46:20 -0000	1.27
  +++ Expand.java	12 Apr 2002 14:10:19 -0000	1.28
  @@ -78,6 +78,8 @@
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
    *
  + * @since Ant 1.1
  + *
    * @ant.task category="packaging"
    *           name="unzip"
    *           name="unjar"
  @@ -101,7 +103,8 @@
           }
   
           if (source == null && filesets.size() == 0) {
  -            throw new BuildException("src attribute and/or filesets must be specified");
  +            throw new BuildException("src attribute and/or filesets must be "
  +                                     + "specified");
           }
   
           if (dest == null) {
  @@ -151,14 +154,14 @@
   
               while ((ze = zis.getNextEntry()) != null) {
                   extractFile(fileUtils, srcF, dir, zis,
  -                            ze.getName(),
  -                            new Date(ze.getTime()),
  +                            ze.getName(), new Date(ze.getTime()),
                               ze.isDirectory());
               }
   
               log("expand complete", Project.MSG_VERBOSE );
           } catch (IOException ioe) {
  -            throw new BuildException("Error while expanding " + srcF.getPath(), ioe);
  +            throw new BuildException("Error while expanding " + srcF.getPath(),
  +                                     ioe);
           } finally {
               if (zis != null) {
                   try {
  @@ -183,7 +186,8 @@
                   String[] incls = p.getIncludePatterns(project);
                   if (incls != null) {
                       for (int w = 0; w < incls.length; w++) {
  -                        boolean isIncl = DirectoryScanner.match(incls[w], name);
  +                        boolean isIncl = 
  +                            DirectoryScanner.match(incls[w], name);
                           if (isIncl) {
                               included = true;
                               break;
  @@ -193,7 +197,8 @@
                   String[] excls = p.getExcludePatterns(project);
                   if (excls != null) {
                       for (int w = 0; w < excls.length; w++) {
  -                        boolean isExcl = DirectoryScanner.match(excls[w], name);
  +                        boolean isExcl = 
  +                            DirectoryScanner.match(excls[w], name);
                           if (isExcl) {
                               included = false;
                               break;
  
  
  
  1.21      +31 -16    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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Touch.java	10 Apr 2002 00:19:54 -0000	1.20
  +++ Touch.java	12 Apr 2002 14:10:19 -0000	1.21
  @@ -85,6 +85,8 @@
    * @author <a href="mailto:mj@servidium.com">Michael J. Sikorsky</a>
    * @author <a href="mailto:shaw@servidium.com">Robert Shaw</a>
    *
  + * @since Ant 1.1
  + *
    * @ant.task category="filesystem"
    */
   public class Touch extends Task {
  @@ -101,7 +103,7 @@
   
       /**
        * Sets a single source file to touch.  If the file does not exist
  -     * an  empty file will be created.
  +     * an empty file will be created.
        */
       public void setFile(File file) {
           this.file = file;
  @@ -132,31 +134,43 @@
        * Execute the touch operation.
        */
       public void execute() throws BuildException {
  +        long savedMillis = millis;
  +
           if (file == null && filesets.size() == 0) {
               throw 
  -                new BuildException("Specify at least one source - a file or a fileset.");
  +                new BuildException("Specify at least one source - a file or "
  +                                   + "a fileset.");
           }
   
           if (file != null && file.exists() && file.isDirectory()) {
               throw new BuildException("Use a fileset to touch directories.");
           }
   
  -        if (dateTime != null) {
  -            DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
  -                                                           DateFormat.SHORT,
  -                                                           Locale.US);
  -            try {
  -                setMillis(df.parse(dateTime).getTime());
  -                if (millis < 0) {
  -                    throw new BuildException("Date of " + dateTime
  -                                             + " results in negative milliseconds value
relative to epoch (January 1, 1970, 00:00:00 GMT).");
  +        try {
  +            if (dateTime != null) {
  +                DateFormat df = 
  +                    DateFormat.getDateTimeInstance(DateFormat.SHORT,
  +                                                   DateFormat.SHORT,
  +                                                   Locale.US);
  +                try {
  +                    setMillis(df.parse(dateTime).getTime());
  +                    if (millis < 0) {
  +                        throw new BuildException("Date of " + dateTime
  +                                                 + " results in negative "
  +                                                 + "milliseconds value "
  +                                                 + "relative to epoch "
  +                                                 + "(January 1, 1970, "
  +                                                 + "00:00:00 GMT).");
  +                    }
  +                } catch (ParseException pe) {
  +                    throw new BuildException(pe.getMessage(), pe, location);
                   }
  -            } catch (ParseException pe) {
  -                throw new BuildException(pe.getMessage(), pe, location);
               }
  -        }
   
  -        touch();
  +            touch();
  +        } finally {
  +            millis = savedMillis;
  +        }
       }
   
       /**
  @@ -216,7 +230,8 @@
   
       protected void touch(File file) throws BuildException {
           if (!file.canWrite()) {
  -            throw new BuildException("Can not change modification date of read-only file
" + file);
  +            throw new BuildException("Can not change modification date of "
  +                                     + "read-only file " + file);
           }
   
           if (Project.getJavaVersion() == Project.JAVA_1_1) {
  
  
  
  1.23      +22 -11    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
  
  Index: Tstamp.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tstamp.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Tstamp.java	18 Mar 2002 02:44:29 -0000	1.22
  +++ Tstamp.java	12 Apr 2002 14:10:19 -0000	1.23
  @@ -79,7 +79,7 @@
    * @author roxspring@yahoo.com
    * @author Conor MacNeill
    * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
  - *
  + * @since Ant 1.1
    * @ant.task category="utility"
    */
   public class Tstamp extends Task {
  @@ -87,6 +87,9 @@
       private Vector customFormats = new Vector();
       private String prefix = "";
   
  +    /**
  +     * @since Ant 1.5
  +     */
       public void setPrefix(String prefix) {
           this.prefix = prefix;
           if (!this.prefix.endsWith(".")) {
  @@ -162,7 +165,8 @@
                       if (st.hasMoreElements()) {
                           variant = st.nextToken();
                           if (st.hasMoreElements()) {
  -                            throw new BuildException( "bad locale format", getLocation());
  +                            throw new BuildException( "bad locale format", 
  +                                                      getLocation());
                           }
                       }
                   }
  @@ -171,7 +175,8 @@
                   }
               }
               catch (NoSuchElementException e) {
  -                throw new BuildException( "bad locale format", e, getLocation());
  +                throw new BuildException( "bad locale format", e, 
  +                                          getLocation());
               }
           }
   
  @@ -185,9 +190,10 @@
   
           /**
            * @deprecated setUnit(String) is deprecated and is replaced with
  -         *             setUnit(Tstamp.Unit) to make Ant's Introspection
  -         *             mechanism do the work and also to encapsulate operations on
  -         *             the unit in its own class.
  +         *             setUnit(Tstamp.Unit) to make Ant's
  +         *             Introspection mechanism do the work and also to
  +         *             encapsulate operations on the unit in its own
  +         *             class.
            */
           public void setUnit(String unit) {
               log("DEPRECATED - The setUnit(String) method has been deprecated."
  @@ -204,11 +210,13 @@
           public void execute(Project project, Date date, Location location)
           {
               if (propertyName == null) {
  -                throw new BuildException("property attribute must be provided", location);
  +                throw new BuildException("property attribute must be provided",
  +                                         location);
               }
   
               if (pattern == null) {
  -                throw new BuildException("pattern attribute must be provided", location);
  +                throw new BuildException("pattern attribute must be provided",
  +                                         location);
               }
   
               SimpleDateFormat sdf;
  @@ -216,10 +224,13 @@
                   sdf = new SimpleDateFormat(pattern);
               }
               else if (variant == null) {
  -                sdf = new SimpleDateFormat(pattern, new Locale(language, country));
  +                sdf = new SimpleDateFormat(pattern,
  +                                           new Locale(language, country));
               }
               else {
  -                sdf = new SimpleDateFormat(pattern, new Locale(language, country, variant));
  +                sdf = new SimpleDateFormat(pattern,
  +                                           new Locale(language, country,
  +                                                      variant));
               }
               if (offset != 0) {
                   Calendar calendar = Calendar.getInstance();
  @@ -260,7 +271,7 @@
   
           public Unit() {
               calendarFields.put(MILLISECOND,
  -                                    new Integer(Calendar.MILLISECOND));
  +                               new Integer(Calendar.MILLISECOND));
               calendarFields.put(SECOND, new Integer(Calendar.SECOND));
               calendarFields.put(MINUTE, new Integer(Calendar.MINUTE));
               calendarFields.put(HOUR, new Integer(Calendar.HOUR_OF_DAY));
  
  
  
  1.23      +3 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Untar.java
  
  Index: Untar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Untar.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Untar.java	3 Mar 2002 01:46:20 -0000	1.22
  +++ Untar.java	12 Apr 2002 14:10:19 -0000	1.23
  @@ -67,11 +67,11 @@
   /**
    * Untar a file.
    *
  - * Heavily based on the Expand task.
  - *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    * @author <a href="mailto:umagesh@rediffmail.com">Magesh Umasankar</a>
    *
  + * @since Ant 1.1
  + *
    * @ant.task category="packaging"
    */
   public class Untar extends Expand {
  @@ -86,8 +86,7 @@
   
               while ((te = tis.getNextEntry()) != null) {
                   extractFile(fileUtils, srcF, dir, tis,
  -                            te.getName(),
  -                            te.getModTime(), te.isDirectory());
  +                            te.getName(), te.getModTime(), te.isDirectory());
               }
               log("expand complete", Project.MSG_VERBOSE );
   
  
  
  
  1.10      +28 -17    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/WaitFor.java
  
  Index: WaitFor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/WaitFor.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- WaitFor.java	3 Mar 2002 01:46:20 -0000	1.9
  +++ WaitFor.java	12 Apr 2002 14:10:19 -0000	1.10
  @@ -83,6 +83,8 @@
    * @author <a href="mailto:denis@network365.com">Denis Hennessy</a>
    * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
    *
  + * @since Ant 1.5
  + *
    * @ant.task category="control"
    */
   
  @@ -134,30 +136,39 @@
        */
       public void execute() throws BuildException {
           if (countConditions() > 1) {
  -            throw new BuildException("You must not nest more than one condition into <waitfor>");
  +            throw new BuildException("You must not nest more than one "
  +                                     + "condition into <waitfor>");
           }
           if (countConditions() < 1) {
  -            throw new BuildException("You must nest a condition into <waitfor>");
  +            throw new BuildException("You must nest a condition into "
  +                                     + "<waitfor>");
           }
           Condition c = (Condition) getConditions().nextElement();
   
  -        maxWaitMillis *= maxWaitMultiplier;
  -        checkEveryMillis *= checkEveryMultiplier;
  -        long start = System.currentTimeMillis();
  -        long end = start + maxWaitMillis;
  -
  -        while (System.currentTimeMillis() < end) {
  -            if (c.eval()) {
  -                return;
  +        long savedMaxWaitMillis = maxWaitMillis;
  +        long savedCheckEveryMillis = checkEveryMillis;
  +        try {
  +            maxWaitMillis *= maxWaitMultiplier;
  +            checkEveryMillis *= checkEveryMultiplier;
  +            long start = System.currentTimeMillis();
  +            long end = start + maxWaitMillis;
  +
  +            while (System.currentTimeMillis() < end) {
  +                if (c.eval()) {
  +                    return;
  +                }
  +                try {
  +                    Thread.sleep(checkEveryMillis);
  +                } catch (InterruptedException e) {
  +                }
               }
  -            try {
  -                Thread.sleep(checkEveryMillis);
  -            } catch (InterruptedException e) {
  -            }
  -        }
   
  -        if (timeoutProperty != null) {
  -            project.setNewProperty(timeoutProperty, "true");
  +            if (timeoutProperty != null) {
  +                project.setNewProperty(timeoutProperty, "true");
  +            }
  +        } finally {
  +            maxWaitMillis = savedMaxWaitMillis;
  +            checkEveryMillis = savedCheckEveryMillis;
           }
       }
   
  
  
  

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


Mime
View raw message