Gradle - 从jar打包中排除文件

Wes*_*Wes 18 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'
}
Run Code Online (Sandbox Code Playgroud)

Som*_*ent 23

你可以尝试这样的东西,我知道这对我有用.在您build.gradleJAR定义下添加您的排除.例如:

jar {     
   exclude('your thing')     
}
Run Code Online (Sandbox Code Playgroud)

  • 排除多个东西使用:`jar {exclude('thing1','thing2')}` (7认同)
  • 我们应该添加什么路径? (3认同)