I'm trying to build a kind of template build script for my java web projects.
This template is stored in my apache web server.
To use it in a project, I use apply from 'http://myserver/templateWarScript.gradle'
.
The configuration for the final war is done in this template.
For all of my java web projects, I need to put the content of a zip file (containing JavaScript files, images, etc) into the final war file. To share this zip file, I put it in my local repository.
Now, I'm trying to find a way to include its content in my final war. But I can't found a way to do it. I'm trying to put the following line in my template script:
configurations {
zipWebResource
}
dependencies {
zipWebResource group: 'utilities.template', name: 'webResource', version: '1.0', ext: 'zip'
}
//test task
task testZipPath << {
println "zip path:" + configurations.zipWebResource.asPath
}
//
//my war configuration
war {
println "zip path:" + configurations.zipWebResource.asPath
}
If I put the 'configurations.zipWebResource.asPath' in the war configuration, I've got an error which shows that gradle can't find the zip dependency.
But, if I remove it from the war configuration, I can read it by my test task.
I've also try to read it in a method or directly in the gradle script, but I've got the same error. After reading the gradle user guide, I think that my problem is linked with the configuration or/and the execution phase.
I would like to understand why I can read the configurations.zipWebResource.asPath in a task but not in a configuration. My goal is to use the zip like a dependency and put it's content in the root of the generated war
Many Thanks.