I am trying to build a war file with Gradle, but I'm having an issue excluding one directory and including another that happen to have the same names, but different parent directories.
Please notice in the first code example below that neither of the css/
directories are being included in the final war
file -- I assume because Gradle thinks that I want to exclude any directory named css/
regardless of its absolute path.
Basically I want to exclude src/main/webapp/css
and include build/tmp/css
because the latter contains the minified code. How can I achieve this? I've tried specifying an absolute path in various ways but haven't had any success.
war {
dependsOn minify
from('build/tmp/') { include ('css/') }
exclude('WEB-INF/classes/', 'css/')
}
If I don't exclude css/
like so:
war {
dependsOn minify
from('build/tmp/') { include ('css/') }
exclude('WEB-INF/classes/')
}
then the result is that both the minified and non-minified code is included.
Within the closure we call exclude , passing: group the group of the artifact we want to exclude. module the name of the artifact we want to exclude. This is equivalent to the name used to declare a dependency in Gradle.
Transitive dependencyBy default, Gradle resolves transitive dependencies automatically. The version selection for transitive dependencies can be influenced by declaring dependency constraints.
The Gradle dependency cache consists of two storage types located under GRADLE_USER_HOME/caches : A file-based store of downloaded artifacts, including binaries like jars as well as raw downloaded meta-data like POM files and Ivy files.
I am not sure why you exclude WEB-INF/classes/css
instead of src/main/webapp/css
in your build.gradle, but copying the minified CSS files instead of the original ones is achieved by:
apply plugin: 'war'
war {
// dependsOn 'minify'
from 'src/main/webapp'
exclude 'css' // or: "exclude 'WEB-INF/classes/css'"
from('build/tmp/css') {
include '**/*.css'
into 'css' // or: "into 'WEB-INF/classes/css'"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With