rubys 02/01/14 06:05:38
Modified: proposal/gump build.xml
proposal/gump/java Jenny.java
Log:
Enable a measure of stability in generated datestamps
Revision Changes Path
1.8 +2 -0 jakarta-alexandria/proposal/gump/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-alexandria/proposal/gump/build.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- build.xml 14 Jan 2002 13:29:34 -0000 1.7
+++ build.xml 14 Jan 2002 14:05:38 -0000 1.8
@@ -21,6 +21,7 @@
<jar file="jenny.jar" basedir="classes"/>
<uptodate property="uptodate" targetfile="work/merge.xml">
+ <srcfiles dir="." includes=".timestamp"/>
<srcfiles dir="." includes="jenny.jar"/>
<srcfiles dir="." includes="${workspace}"/>
<srcfiles dir="profile" includes="*.xml"/>
@@ -107,6 +108,7 @@
<!-- Remove all outputs and intermediate results -->
<target name="clean">
+ <delete file=".timestamp"/>
<delete file="jenny.jar"/>
<delete dir="classes"/>
<delete dir="work"/>
1.10 +21 -6 jakarta-alexandria/proposal/gump/java/Jenny.java
Index: Jenny.java
===================================================================
RCS file: /home/cvs/jakarta-alexandria/proposal/gump/java/Jenny.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Jenny.java 11 Jan 2002 00:59:46 -0000 1.9
+++ Jenny.java 14 Jan 2002 14:05:38 -0000 1.10
@@ -16,6 +16,7 @@
import org.xml.sax.SAXParseException;
// Java classes
+import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
@@ -25,7 +26,6 @@
DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
TransformerFactory tFactory = TransformerFactory.newInstance();
- String dstamp = (new SimpleDateFormat("yyyyMMdd")).format(new Date());
/**
* Parse an XML source file into an DOM.
@@ -45,9 +45,13 @@
/**
* Replace all occurances of @@DATE@@ with the current datestamp in
- * attribute values.
+ * attribute values. The datestamp to be used is persisted on disk,
+ * so it will remain stable until the .timestamp file is touched or
+ * removed.
+ * @param parent node to be processed recursively
+ * @param dstamp string to substitute for @@DATE@@
*/
- private void replaceDate(Element parent) {
+ private void replaceDate(Element parent, String dstamp) {
Node first = parent.getFirstChild();
for (Node child=first; child != null; child=child.getNextSibling()) {
if (child.getNodeType()==Node.ELEMENT_NODE) {
@@ -61,7 +65,7 @@
((Element)child).setAttribute(a.getNodeName(),v);
}
}
- replaceDate((Element)child);
+ replaceDate((Element)child, dstamp);
}
}
}
@@ -192,12 +196,23 @@
* @param source document to be transformed
*/
private Jenny(String source) throws Exception {
+
+ // Obtain the date to be used
+ Date lastModified = new Date();
+ try {
+ File timestamp = new File(".timestamp");
+ timestamp.createNewFile();
+ lastModified = new Date(timestamp.lastModified());
+ } catch (java.io.IOException ioe) {
+ }
+ String dstamp = (new SimpleDateFormat("yyyyMMdd")).format(lastModified);
+
+ // process documents
Document doc = parse(source);
Element workspace = (Element)doc.getFirstChild();
Workspace.init(workspace);
-
expand(workspace);
- replaceDate(workspace);
+ replaceDate(workspace, dstamp);
Repository.load(merge("repository", workspace).elements());
Module.load(merge("module",workspace).elements());
Project.load(merge("project",workspace).elements());
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>