OK, now I’m getting an internal error. I’m thinking that what I am doing may be overkill, and that there is probably a better way. What I’m trying to do is create multiple war’s, one for each environment that we are deploying to. Each war is tweaked in a consistent way - each environment has its own properties files, xml config files, etc.
Anyway, first off the code and internal error:
class CustomWar extends War {
def env = '';
CustomWar(){
super()
//dependsOn 'checkArtifacts'
//exclude the local web.xml from the build
exclude '**/web.xml'
//copy properties files to classes
from (env){
include '*.properties'
into '/WEB-INF/classes'
}
// copies a file to WEB-INF/web.xml
webXml = project.file(env + '/web.xml')
}
}
Error message:
:compileJava Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. :processResources UP-TO-DATE :classes :bentallProdWar
FAILURE: Build aborted because of an internal error.
-
What went wrong: Build aborted because of an unexpected internal error. Please file an issue at: http://forums.gradle.org.
-
Try: Run with --debug option to get additional debug info.
-
Exception is: java.lang.IllegalArgumentException: Neither path nor baseDir may be null or empty string. path=’’ basedir=‘C:\eclipseProjects\sustainability’
at org.gradle.api.internal.file.BaseDirFileResolver.doResolve(BaseDirFileResolver.java:67)
at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:57)
at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:53)
at org.gradle.api.internal.file.collections.DefaultFileCollectionResolveContext$FileTreeConverter.convertInto(DefaultFileCollectionResolveContext.java:200)
Regardless of the above, I believe I found the solution to my problem, from Rene:
http://www.mail-archive.com/user@gradle.codehaus.org/msg06259.html
This looks like exactly what I need:
["kung", "foo", "bar", ].each{env ->
task "${env}War"(type:War){
baseName = "${env}"
from "target/${env}-tmp"
}
}
For me, this is quite alien. Very much so. However, I am starting to see how this is the ‘gradle way’ and it makes sense now that I’m starting to understand more about how gradle works. I only wish this example was somewhere in the docs, would have saved me quite a bit of time…
Thanks for the help!
Mark