Java – gradle: conflict inclusion / exclusion of war missions
I'm trying to build a war file using gradle, but I have a problem. It excludes one directory and contains another directory with exactly the same name but different parent directory
Note that in the first code example below, the CSS / directory is not included in the final war file - I assume because gradle thinks 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 reduced code How can I do this? I have tried to specify absolute paths in various ways without any success
war { dependsOn minify from('build/tmp/') { include ('css/') } exclude('WEB-INF/classes/','css/') }
If I do not exclude CSS / like, then:
war { dependsOn minify from('build/tmp/') { include ('css/') } exclude('WEB-INF/classes/') }
The result then includes reduced and non reduced code
Solution
I'm not sure why in build WEB-INF / classes / CSS is excluded from gradle instead of Src / main / webapp / CSS, but the reduced CSS file is copied instead of the original CSS file in the following ways:
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'" } }