War plugin custom webAppDirName and generated files


I am using gradle 1.8 and war plugin. I would like to use different war source dir and I woud like to generate there new files and modify files copied from src/main/webapp.

my script (shortened) looks like this:

apply plugin: ‘war’

apply plugin: WebappPlugin war.dependsOn(project.tasks.wro) //wro does generate new files and modify //existing files, these files are copied into buildGradle/tmpSrc/espWebAppWork




srcDirs = [‘src/main/java’,‘buildGradle/tmpSrc/espWebAppWork’]


} }


extraLibs {

transitive = false



transitive = false

} }

evaluationDependsOn(’:esWebAPI’) war.dependsOn(’:esWebAPI:war’)

dependencies {

compile project(’:esWebAPI’)

compile project(’:esSpringSecurity’)

//plugin dependency, kept here as we don’t have separated plugin build

pluginDependencies libraries.wro }


war {


archiveName = “${project.name}.war”

from zipTree ( project(’:esWebAPI’).war.archivePath )



classpath = configurations.extraLibs //empty as all dependencies are taken from esWebAPI }

I tried set the webAppDirName as project property too, but nothing works. I found the path to the project.convention.plugins.war.webAppDirName in the gradle source code, but it helped only partially. Files which are only copied and modified are used, but files which I have generated in the wro tasks are not present in the final war file.

Found in one post that the directory must be in the sourceSets, but that doesn’t work either.

How could I use non default war source directory with generated files in that directory by tasks which is dependency to the war task?

Thanks. Regards, Zdenek

I use project.convention.plugins.war.webAppDirName to specify the war source directory