【问题标题】:Gradle - Exclude file from being packaged with jarGradle - 排除文件与 jar 打包
【发布时间】:2016-12-04 11:13:02
【问题描述】:

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

【问题讨论】:

    标签: java gradle properties-file


    【解决方案1】:

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

    jar {     
       exclude('your thing')     
    }
    

    【讨论】:

    • 用于排除不止一种用途:jar { exclude('thing1', 'thing2')}
    • 我们应该添加什么路径?
    • 有没有办法将属性文件放在与 src 不同的目录中,然后指示 Gradle 在运行测试时使用包含属性文件的更新类路径?
    猜你喜欢
    • 2019-04-23
    • 2016-01-28
    • 1970-01-01
    • 2017-01-31
    • 2018-04-01
    • 2018-01-04
    • 2016-01-29
    • 2020-02-01
    • 1970-01-01
    相关资源
    最近更新 更多