Nabor
Nabor

Reputation: 1701

Gradle task take over configuration of war

For my web project I need to build two WAR files. One with the static content, one without.

war {
    archiveName = "feeder##${version}.full.war"
    exclude 'test.html', 'test.js', 'todos.js'
}
task SmallWar(type: War, dependsOn:[war]) {
    // exclude 'css', 'img', 'js', 'template', 'index.html'
    archiveName = "feeder##${version}.war"
}

It's clear, I'm able to configure both the same way, but how can I take over the configuration and enhance it?
The current configuration only calls war before running SmallWar.
I don't want to call it. Instead the SmallWar task should already exclude the same files as the war plus additional files.

Upvotes: 1

Views: 448

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123900

The dependsOn only affects execution, not configuration. An easy way to configure commonalities between the two War tasks is:

tasks.withType(War) {
    exclude 'test.html', 'test.js', 'todos.js'
}

smallWar can then add further excludes:

task smallWar(type: War) {
    exclude 'css', 'img', 'js'
}

Upvotes: 2

Related Questions