Gradle - 排除文件与 jar 一起打包

问题描述 投票:0回答:1

我想从构建的罐子中排除

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'
}
java gradle properties-file
1个回答
36
投票

你可以尝试这样的方法,我知道这对我有用。在

build.gradle
定义下的
JAR
中添加您的 exclude。例如:

jar {     
   exclude('your thing')     
}
© www.soinside.com 2019 - 2024. All rights reserved.