How to think about the execution of the from methods on the WAR task

(Trent Rosenbaum) #1

Hi there,

This week I have been replacing an Ant script with Gradle and it has been really productive. I had a situation where I needed to only process the JSP files in and replace a token. So code like the following was used.

war {
    def myValue = 'my value'
      from(webAppDirName) {
        include '**/*.jsp'
        eachFile {
            it.filter(, tokens: ['myValue': myValue])

So I got the result I wanted and the JSP file had their tokens replaced. My question is about how to think of this ‘from’ method execution in relation to the defaults ‘from’ methods that are used with the WAR plugin. Is it best to think of this one as being added to a collective object that does a single pass over the resources and then applies the ‘from’ closures to a file that matches the include values? In this example am I just say to the War task to do another pass over the resources represented by ‘webAppDirName’ after the original copy?

It seems like a silly question, but I am just starting out with Gradle and I just need a pointer to switch on some understanding about this type of problem. Maybe there is a better way to process tokens in resources?

Any feedback would be great. Trent