soapergem
soapergem

Reputation: 10019

How do I get this Jar task to include resource files in Gradle?

I'm inheriting a Gradle project, and I admittedly know very little about Gradle. In my build.gradle file, the following task is defined, which builds a JAR with all of the necessary dependencies:

task jarWithDependents(type: Jar, dependsOn: [clean, jar]) {
    from files(sourceSets.main.output.classesDir)
    from { configurations.compile.collect { zipTree(it) } }

    manifest {
        attributes 'Main-Class': 'com.packagename.Main'
    }
}

The trouble is that this task doesn't include any of the files that I've put in my resources folder in the final JAR. How do I modify this code to ensure that the resource files are packaged inside the JAR?

Upvotes: 0

Views: 2172

Answers (1)

Mark Vieira
Mark Vieira

Reputation: 13476

You are only including the class file output. If you want to include all SourceSet output do:

from sourceSets.main.output

Upvotes: 1

Related Questions