简体   繁体   中英

How to Exclude directory and its contents in gradle war

I am using gradle war plugin, I am trying to exclude some directories inside WEB-INF directory while packing a war, but the excludes don't seem to work. This is what I have

 war {
   webInf {
        from 'src/main/config'
    }
   exclude('metadata/**')
  }

Any solution on this ?

To a folder named metadata contained in WEB-INF use the following code in your build.gradle file:WEB-INF包含的名为metadata的文件夹,请在 build.gradle 文件中使用以下代码:

war.rootSpec.exclude("**/WEB-INF/metadata/")

or depending on your coding style you could also use:

war 
{ 
    rootSpec.exclude("**/WEB-INF/metadata/") 
}

This link on the gradle discussion forum may also be of help

Are you looking for something like this http://gradle.1045684.n5.nabble.com/Exclude-properties-file-from-war-td3365147.html ? If so only remember, that in recent versions of Gradle (I'm using 1.6) there's sourceSets.main.output . It'd helpful if you could specify what metadata is and attach your project's layout.

One more thing: you may also like to:

//remove jars only for provided compile
classpath -= configurations.providedCompile

see this post and comments

war {
// remove classes from the classpath <<<<<<<
classpath = configurations.runtime

// add them in explicitly, with the filtering applied
webInf {
    into('classes') {
        from sourceSets.main.classes
        exclude 'org/gradle/sample/excludeme/**'
    }
}
}
sourceSets {
    main {
        src {
            srcDir 'config'
            exclude 'metadata/**'
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM