filtercopygant

Gant: Copy with filtering


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!


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")
    }