Question

I have a 'doc' directory containing HTML documentation and each HTML contains placeholders for the application version and the SVN revision:

Welcome to the ... V${version} r${buildNumber}

In my Grails/Gant build script we create a doc package for which we first copy the doc directory to a staging area before zipping it up. I now wanna replace these placeholders with values like this (assume the variables appVersion and svnRevision are set properly:

ant.mkdir(dir: "${baseDocDir}")
ant.copy(todir: "${baseDocDir}") {
   fileset(dir: "./src/main/doc", includes: '*.html')
   filterset {
     filter ( token : 'version' , value: appVersion )
     filter ( token : 'buildNumber' , value : svnRevision )
   }
}

The copy works but somehow the filter does not!

Was it helpful?

Solution

I can answer the question myself now. The following code works:

ant.copy(todir: "${baseDocDir}") {
  filterset(begintoken: "\${", endtoken: "}") {
    filter(token: "version", value: appVersion)
    filter(token: "buildNumber", value: svnRevision)
  }
  fileset(dir: "./src/main/doc/", includes: "**/*.html")
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top