Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 26201 invoked by uid 500); 20 Sep 2001 15:21:49 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 26180 invoked from network); 20 Sep 2001 15:21:49 -0000 Date: 20 Sep 2001 15:21:49 -0000 Message-ID: <20010920152149.5823.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: ant-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 3751] New: - Enhancement to "Replace" task when useing "propertyFile" attribute. X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . 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=3751 Enhancement to "Replace" task when useing "propertyFile" attribute. Summary: Enhancement to "Replace" task when useing "propertyFile" attribute. Product: Ant Version: 1.4 Platform: All OS/Version: Other Status: NEW Severity: Enhancement Priority: Other Component: Core tasks AssignedTo: ant-dev@jakarta.apache.org ReportedBy: bruce.elliott@knowledgenet.com The use of a propertyFile allows great flexibility in the Replace task. But when the propertyFile attribute is used, it requires that replacefilters are created which specify which token will be replaced by the value associated with a given property key. Complex files may have very large numbers of tokens to be replaced. They may also be in a state of flux, where the number and name of tokens to replace changes frequently. This starts to become a maintenance issue. One option, presented here, is to allow the following alternative. If a propertyFile is used and there are no task attribute nor nested replacefilte(s) tasks, use the propertyFile key(s) as the token to replace and replace it with the associated propertyFile value(s). This allows the ant build file to remain unchanged even as the source file and the propertyFile continue to evolve. The change specified above was made on our version of Ant1.4. It is very convenient. A diff of the original Replace.java file and the modified version is included below. 190a191,204 > if (token == null && replacefilters.size() == 0) { > Enumeration props = properties.propertyNames(); > String prop; > String value; > Replacefilter filter; > while (props.hasMoreElements()) { > prop = (String)props.nextElement(); > value = (String)properties.getProperty(prop); > filter = new Replacefilter(); > filter.setToken(prop); > filter.setValue(value); > replacefilters.add(filter); > } > } 231c245 < if (token == null && replacefilters.size() == 0) { --- > if (token == null && replacefilters.size() == 0 && propertyFile == null) { 233c247 < + "must be specified"; --- > + "must be specified when no property file is specified";