Am 09.11.10 21:21, schrieb Philippe Lhoste:
> On 09/11/2010 12:18, chris wrote:
>> Any way I can get some re-use here?
>
> Not sure if that's the best way (I am a Gradle beginner) but it might
> be a case for the task generation I saw (and wondered about the
> usefulness) in the Getting Started page.
>
> Something like:
>
> def makeWarTask(id) {
> task "war$id"(type: War, dependsOn: packaging) {
> if (id == 1) bn = 'first' else bn = 'second'
> baseName = "$bn-$baseName"
> webInf {
> from fileTree("$webAppDir/WEB-INF-$id")
> }
> into ('WEB-INF/classes') {
> from rootProject.file('build-gradle')
> }
> into ('WEB-INF/classes') {
> from fileTree(sourceSets.main.classesDir)
> include('com/foo/web/**/*')
> }
> }
> }
>
> 2.times {
> n -> makeWarTask(n)
> }
>
> Might need some adjustments, as I know nothing about Groovy beside
> what I learned with Gradle...
>
to make it a bit groovier you could rewrite the above snippet to:
-------------------
['first','second'].eachWithIndex{ bn, idx ->
task "war$idx"(type: War, dependsOn: packaging) {
baseName = "$bn-$baseName"
webInf {
from fileTree("$webAppDir/WEB-INF-$idx")
}
into ('WEB-INF/classes') {
from rootProject.file('build-gradle')
}
into ('WEB-INF/classes') {
from fileTree(sourceSets.main.classesDir)
include('com/foo/web/**/*')
}
}
}
regards,
René
-------------------
--
------------------------------------
Rene Groeschke
[email protected]
http://www.breskeby.com
http://twitter.com/breskeby
------------------------------------
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email