```I am using a war task in my gradle project, The...
# community-support
f
Copy code
I am using a war task in my gradle project, The idea is to get the web.xml file in war artifact created and in that copied file there is one parameter <param-value>${springActiveProfile}</param-value>which should have the value given in def springActiveProfile = 'sync,prodPropertySetup'.
But my below added task is not working as it is not editing the web.xml
Copy code
def springActiveProfile = 'sync,prodPropertySetup'
war {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    archiveBaseName = "Sync"

    // Normal webapp content
    from("src/main/webapp")

    // Override just web.xml with expansion
    from("src/main/webapp/WEB-INF") {
        include "web.xml"
        into "WEB-INF"
        expand(springActiveProfile: springActiveProfile)
    }
}
s
you may need to explicitly exclude the WEB-INF/web.xml from the first ‘from’ (just guessing)
f
yes I tried that also but war plugin is not allowing to edit, meanwhile I have implemented this way and it is working
Copy code
tasks.register('customWar', Jar){
    //source and target info
    ...
}
v
From the original snippet, remove the duplicates strategy, there is almost no valid use-case for one. Whenever you need one, almost always you should fix the underlying problem, not fight the symptom. Then remove the second from that makes no sense, and instead use
filesMatching
to do the expansion on just the one file you want it to. :-)
👍 1
And of course remove also the first from, as that is already the default and you just include all the files a second time