java Gradle - 排除文件与 jar 一起打包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38663838/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gradle - Exclude file from being packaged with jar
提问by Wes
I want to excludeAMAuthN.properties
from the built jar. This file keeps showing up in the root folder of the compiled jar. The file is located at AMAuthN\src\main\resources\AMAuthN.properties
relative to the project folder root. Thanks!
我想从构建的 jar 中排除AMAuthN.properties
。该文件一直显示在已编译 jar 的根文件夹中。该文件位于AMAuthN\src\main\resources\AMAuthN.properties
相对于项目文件夹根目录。谢谢!
apply plugin: 'java'
apply plugin: 'eclipse'
version = '1.0'
sourceCompatibility = 1.6
targetCompatibility = 1.6
test {
testLogging {
showStandardStreams = true
}
}
// Create a single Jar with all dependencies
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'com.axa.openam'
}
baseName = project.name
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
// Get dependencies from Maven central repository
repositories {
mavenCentral()
}
// Project dependencies
dependencies {
compile 'com.google.code.gson:gson:2.5'
testCompile 'junit:junit:4.12'
}
回答by SomeStudent
You can try something like this, which i know works on my end. In your build.gradle
under the JAR
definition add your exclude. Ex:
你可以尝试这样的事情,我知道这对我有用。在您build.gradle
的JAR
定义下添加您的exclude。前任:
jar {
exclude('your thing')
}