Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - Exclude file from being packaged with jar

Tags:

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' } 
like image 776
Wes Avatar asked Jul 29 '16 16:07

Wes


People also ask

How do I exclude tasks in Gradle?

To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build. As a result, the test sources aren't compiled, and therefore, aren't executed.

How do you avoid transitive dependencies in Gradle?

Excluding a dependency from a configuration completely Similar to excluding a dependency in a dependency declaration, you can exclude a transitive dependency for a particular configuration completely by using Configuration. exclude(java. util. Map).

Where does Gradle Place jar files?

The Jar is created under the $project/build/libs/ folder.


1 Answers

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')      } 
like image 166
SomeStudent Avatar answered Oct 06 '22 14:10

SomeStudent