ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 3751] New: - Enhancement to "Replace" task when useing "propertyFile" attribute.
Date Thu, 20 Sep 2001 15:21:49 GMT
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=3751>.
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";

Mime
View raw message