Gradle: The war task has Conflicts Enable / Exclude

I am trying to create a war file with Gradle, but I have a problem that excludes one directory and includes another that has the same name but different parent directories.

Note that in the first code example below, none of the css/ directories is included in the final war file - I assume because Gradle believes that I want to exclude any named css/ directory, regardless of its absolute path.

Basically I want to exclude src/main/webapp/css and enable build/tmp/css , because the latter contains a mini code. How can I achieve this? I tried to point the absolute path in various ways, but had no success.

 war { dependsOn minify from('build/tmp/') { include ('css/') } exclude('WEB-INF/classes/', 'css/') } 

If I do not exclude css/ like this:

 war { dependsOn minify from('build/tmp/') { include ('css/') } exclude('WEB-INF/classes/') } 

the result is that both minified and non-reduced code are included.

+7
source share
1 answer

I'm not sure why you exclude WEB-INF/classes/css instead of src/main/webapp/css in your build.gradle, but copying the CSS mini files instead of the original ones is done 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'" } } 
+5
source

All Articles