java - Gradle - 排除文件与 jar 打包

标签 java gradle properties-file

我想从构建的 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'
}

最佳答案

您可以尝试这样的操作,我知道它对我有效。在 JAR 定义下的 build.gradle 中添加您的 exclude。例如:

jar {     
   exclude('your thing')     
}

关于java - Gradle - 排除文件与 jar 打包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38663838/

相关文章:

java - 在 Java 中强制注释之后及其元素之前不留空格

multithreading - 我可以停止 javaexec 失败并终止 Gradle 任务吗?

java - 从属性文件中读取

java - Spring Boot中加载配置文件问题

java - 使用 Maven 配置文件加载正确的属性文件时获取 NPE

java - 绘制背景使我的应用变慢

java - 有人可以看一下 java LinkedList 的 m remove() 方法吗?

java - 有多少个 Java 垃圾收集器对象?

切换到 gradle 后,android 自定义 View 属性不起作用

android - 我在签名时似乎无法构建我的android应用程序