Exclude jars from WAR folder?

I need to exclude two .jar files from my webapp output file. The build.gradle file looks like this:

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.30'
    compile 'javax.servlet:servlet-api:2.5'
    compile project(':farms')
} 

war {
    exclude("**/bad1.jar")
    exclude("**/bad2.jar")
}

The "farm" project is what includes the bad1.jar and bad2.jar banks. I do not need them, although a weekend war. The exceptional block that I was trying to add has no effect.

How can I prevent these banks from being added?

+4
source share
2 answers

This has worked for me in the past:

war {
    rootSpec.exclude("**/bad1.jar")
    rootSpec.exclude("**/bad2.jar")
}
+2
source

I'm not sure if exclude supports lazy, but I would try this:

excludes {['**/bad1.jar', '**/bad2.jar']}

Something else that you could do, which I did before, is to install for only those files that you want.

/**
 * Get a FileTree using a String array of includePatterns and String array of excludePatterns
 * @return FileTree
 */
ext.getFiles = {List includePattern=null, List excludePattern=null ->
    FileTree fileTree = project.fileTree(dir: project.getRootDir())
    if (includePattern) {
        includePattern.each {
            fileTree.include(it)
        }
    }
    if (excludePattern) {
        excludePattern.each {
            fileTree.exclude(it)
        }
    }
    return fileTree
}

In your military mission

from { getFiles(includePattern, excludePattern).files }

, includePattern, , excludePattern's. , . , . , , : dir: project.getRootDir() - .

0

All Articles