Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 76203 invoked from network); 2 Sep 2007 12:53:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Sep 2007 12:53:43 -0000 Received: (qmail 94894 invoked by uid 500); 2 Sep 2007 12:53:37 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 94582 invoked by uid 500); 2 Sep 2007 12:53:36 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 94571 invoked by uid 500); 2 Sep 2007 12:53:36 -0000 Received: (qmail 94568 invoked by uid 99); 2 Sep 2007 12:53:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Sep 2007 05:53:36 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Sep 2007 12:54:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 16EDE1A9832; Sun, 2 Sep 2007 05:53:18 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r571970 - in /ant/core/trunk: WHATSNEW docs/manual/CoreTasks/touch.html src/main/org/apache/tools/ant/taskdefs/Touch.java Date: Sun, 02 Sep 2007 12:53:17 -0000 To: ant-cvs@apache.org From: jkf@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070902125318.16EDE1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jkf Date: Sun Sep 2 05:53:16 2007 New Revision: 571970 URL: http://svn.apache.org/viewvc?rev=571970&view=rev Log: Improvement of handling mappers in the touch task. datetime and millis now take precedence over the timestamp on the original file. Bugzilla report 43235. Modified: ant/core/trunk/WHATSNEW ant/core/trunk/docs/manual/CoreTasks/touch.html ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=571970&r1=571969&r2=571970&view=diff ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Sun Sep 2 05:53:16 2007 @@ -21,6 +21,10 @@ in Ant 1.7.0 has been removed. Bugzilla report 40511. +* In the task when a is used, the millis and datetime + attributes now override the time of the source resource if provisioned. + Bugzilla report 43235. + Fixed bugs: ----------- Modified: ant/core/trunk/docs/manual/CoreTasks/touch.html URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/touch.html?rev=571970&r1=571969&r2=571970&view=diff ============================================================================== --- ant/core/trunk/docs/manual/CoreTasks/touch.html (original) +++ ant/core/trunk/docs/manual/CoreTasks/touch.html Sun Sep 2 05:53:16 2007 @@ -56,7 +56,9 @@ datetime - Specifies the new modification time of the file. + Specifies the new modification time of the file. The + special value "now" indicates the current time + (now supported since Ant 1.8). pattern @@ -99,9 +101,12 @@ mapper can be specified. Files specified via nested filesets, filelists, or the file attribute are mapped using the specified mapper. For each file mapped, - the resulting files are touched. If the original file exists its - timestamp will be used. Otherwise the task settings (millis, - datetime) take effect.

+ the resulting files are touched. If no time has been specified and + the original file exists its timestamp will be used. + If no time has been specified and the original file does not exist the + current time is used. Since Ant 1.8 the task settings (millis, + and datetime) have priority over the timestamp of the original + file.

Examples

  <touch file="myfile"/>

creates myfile if it doesn't exist and changes the @@ -126,6 +131,14 @@

creates bar if it doesn't exist and changes the modification time to that of foo.

+ +
  <touch file="foo" datetime="now">
+    <mapper type="regexp" from="^src(.*)\.java" to="shadow\1.empty" />
+  </touch>
+
+

creates files in the shadow directory for every java file in the + src directory if it doesn't exist and changes the modification + time of those files to the current time.

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java?rev=571970&r1=571969&r2=571970&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Touch.java Sun Sep 2 05:53:16 2007 @@ -231,44 +231,48 @@ } if (dateTime != null && !dateTimeConfigured) { long workmillis = millis; - DateFormat df = dfFactory.getPrimaryFormat(); - ParseException pe = null; - try { - workmillis = df.parse(dateTime).getTime(); - } catch (ParseException peOne) { - df = dfFactory.getFallbackFormat(); - if (df == null) { - pe = peOne; - } else { - try { - workmillis = df.parse(dateTime).getTime(); - } catch (ParseException peTwo) { - pe = peTwo; + if ("now".equalsIgnoreCase(dateTime)) { + workmillis = System.currentTimeMillis(); + } else { + DateFormat df = dfFactory.getPrimaryFormat(); + ParseException pe = null; + try { + workmillis = df.parse(dateTime).getTime(); + } catch (ParseException peOne) { + df = dfFactory.getFallbackFormat(); + if (df == null) { + pe = peOne; + } else { + try { + workmillis = df.parse(dateTime).getTime(); + } catch (ParseException peTwo) { + pe = peTwo; + } } } - } - if (pe != null) { - throw new BuildException(pe.getMessage(), pe, getLocation()); - } - if (workmillis < 0) { - throw new BuildException("Date of " + dateTime - + " results in negative " - + "milliseconds value " - + "relative to epoch " - + "(January 1, 1970, " - + "00:00:00 GMT)."); + if (pe != null) { + throw new BuildException(pe.getMessage(), pe, getLocation()); + } + if (workmillis < 0) { + throw new BuildException("Date of " + dateTime + + " results in negative " + "milliseconds value " + + "relative to epoch " + "(January 1, 1970, " + + "00:00:00 GMT)."); + } } log("Setting millis to " + workmillis + " from datetime attribute", - ((millis < 0) ? Project.MSG_DEBUG : Project.MSG_VERBOSE)); + ((millis < 0) ? Project.MSG_DEBUG : Project.MSG_VERBOSE)); setMillis(workmillis); - //only set if successful to this point: + // only set if successful to this point: dateTimeConfigured = true; } } /** * Execute the touch operation. - * @throws BuildException if an error occurs. + * + * @throws BuildException + * if an error occurs. */ public void execute() throws BuildException { checkConfiguration(); @@ -339,8 +343,10 @@ } else { String[] mapped = fileNameMapper.mapFileName(r.getName()); if (mapped != null && mapped.length > 0) { - long modTime = (r.isExists()) ? r.getLastModified() - : defaultTimestamp; + long modTime = defaultTimestamp; + if (millis < 0 && r.isExists()){ + modTime = r.getLastModified(); + } for (int i = 0; i < mapped.length; i++) { touch(getProject().resolveFile(mapped[i]), modTime); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org