|
@@ -32,6 +32,7 @@ import java.util.Vector; |
|
|
|
|
|
|
|
|
import org.apache.tools.ant.BuildException; |
|
|
import org.apache.tools.ant.BuildException; |
|
|
import org.apache.tools.ant.Location; |
|
|
import org.apache.tools.ant.Location; |
|
|
|
|
|
import org.apache.tools.ant.MagicNames; |
|
|
import org.apache.tools.ant.Project; |
|
|
import org.apache.tools.ant.Project; |
|
|
import org.apache.tools.ant.Task; |
|
|
import org.apache.tools.ant.Task; |
|
|
import org.apache.tools.ant.types.EnumeratedAttribute; |
|
|
import org.apache.tools.ant.types.EnumeratedAttribute; |
|
@@ -68,7 +69,7 @@ public class Tstamp extends Task { |
|
|
*/ |
|
|
*/ |
|
|
public void execute() throws BuildException { |
|
|
public void execute() throws BuildException { |
|
|
try { |
|
|
try { |
|
|
Date d = new Date(); |
|
|
|
|
|
|
|
|
Date d = getNow(); |
|
|
|
|
|
|
|
|
Enumeration i = customFormats.elements(); |
|
|
Enumeration i = customFormats.elements(); |
|
|
while (i.hasMoreElements()) { |
|
|
while (i.hasMoreElements()) { |
|
@@ -109,6 +110,22 @@ public class Tstamp extends Task { |
|
|
getProject().setNewProperty(prefix + name, value); |
|
|
getProject().setNewProperty(prefix + name, value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Return the {@link Date} instance to use as base for DSTAMP, TSTAMP and TODAY. |
|
|
|
|
|
*/ |
|
|
|
|
|
protected Date getNow() { |
|
|
|
|
|
String magicNow = getProject().getProperty(MagicNames.TSTAMP_NOW); |
|
|
|
|
|
if (magicNow != null && magicNow.length() > 0) { |
|
|
|
|
|
try { |
|
|
|
|
|
return new Date(1000 * Long.parseLong(magicNow)); |
|
|
|
|
|
} catch (NumberFormatException ex) { |
|
|
|
|
|
log("magic property " + MagicNames.TSTAMP_NOW + " ignored as " |
|
|
|
|
|
+ magicNow + " is not a valid number"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return new Date(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* This nested element that allows a property to be set |
|
|
* This nested element that allows a property to be set |
|
|
* to the current date and time in a given format. |
|
|
* to the current date and time in a given format. |
|
|