Gradle - 排除文件与 jar 一起打包 [英] Gradle - Exclude file from being packaged with jar

查看:62
本文介绍了Gradle - 排除文件与 jar 一起打包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从构建的 jar 中排除 AMAuthN.properties.该文件一直显示在已编译 jar 的根文件夹中.该文件位于相对于项目文件夹根目录的 AMAuthN\src\main\resources\AMAuthN.properties.谢谢!

I want to exclude AMAuthN.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!

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

推荐答案

你可以尝试这样的事情,我知道这对我有用.在 JAR 定义下的 build.gradle 中,添加您的 exclude.例如:

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:

jar {     
   exclude('your thing')     
}

这篇关于Gradle - 排除文件与 jar 一起打包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆