简体   繁体   English

Gradle - 从jar打包中排除文件

[英]Gradle - Exclude file from being packaged with jar

I want to exclude AMAuthN.properties from the built jar. 我想从构建的jar中排除 AMAuthN.properties This file keeps showing up in the root folder of the compiled jar. 此文件一直显示在已编译jar的根文件夹中。 The file is located at AMAuthN\\src\\main\\resources\\AMAuthN.properties relative to the project folder root. 该文件位于相对于项目文件夹根目录的AMAuthN\\src\\main\\resources\\AMAuthN.properties Thanks! 谢谢!

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'
}

You can try something like this, which i know works on my end. 你可以尝试这样的东西,我知道这对我有用。 In your build.gradle under the JAR definition add your exclude . JAR定义下的build.gradle添加您的排除 Ex: 例如:

jar {     
   exclude('your thing')     
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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