DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12829>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12829 <tstamp><format> nested element ignores prefix Summary: <tstamp><format> nested element ignores prefix Product: Ant Version: 1.5 Platform: All OS/Version: Other Status: NEW Severity: Major Priority: Other Component: Core tasks AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] This bug is major with respect to the operation of the <tstamp> task. >From looking at the code and reading the docs, I infer that <tstamp prefix="start"> <format property="TODAY_UK" pattern="d-MMMM-yyyy" locale="en"/> </tstamp> should set the "start.TODAY_UK" property. It doesn't. The task currently ignores the prefix and sets the "TODAY_UK" property instead. This is because the <format> nested elements are created before the <tstamp> attributes are set. Suggested fix: * Remove the prefix field variable from the "CustomFormat" class and let it be inheritted. Perform prefix computation within execute. 1) Change the createFormat() method public CustomFormat createFormat() { // CustomFormat cts = new CustomFormat(prefix); CustomFormat cts = new CustomFormat(); customFormats.addElement(cts); return cts; } 2) Remove the prefix field and change the constructor of CustomFormat private int offset = 0; private int field = Calendar.DATE; // private String prefix = ""; /** * Create a format with the current prefix * @param prefix */ public CustomFormat(String prefix) { // this.prefix = prefix; } 3) Remove the prefix concatenation from the setProperty() method public void setProperty(String propertyName) { // this.propertyName = prefix + propertyName; this.propertyName = propertyName; } 4) Relocate it to the bottom of the execute() method public void execute(Project project, Date date, Location location) { ... // project.setNewProperty(propertyName, sdf.format(date)); project.setNewProperty(prefix + propertyName, sdf.format(date)); } Suggested unit test: The following test (or its equivalent) should be added to TStampTest.java: public void testFormatPrefix() throws Exception { Tstamp.CustomFormat format = tstamp.createFormat(); format.setProperty("format"); format.setPattern("HH:mm:ss z"); format.setTimezone("GMT"); tstamp.setPrefix("prefix"); tstamp.execute(); String prop= project.getProperty("prefix.format"); assertNotNull(prop); } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
