3

I am using the ShadowJar Gradle plugin to build a Jar containing all of the source files in the src/main/java directory and other Jar files in a lib directory and it is working fine. What I need is another ShadowJar task, a devShadowJar task, that will instead of pulling in a JSON file in the src/main/resources folder, it will pull in a JSON file in the src/dev/resources folder.

I added this to the build.gradle file to define the dev source set:

sourceSets {
    dev
}

But now I am not sure how to create a devShadowJar task to use the dev JSON resource instead of the JSON resource file located in src/main/resources.

tim_yates
  • 167,322
  • 27
  • 342
  • 338
anthonylawson
  • 761
  • 9
  • 24

1 Answers1

5

try playing around this:

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

task devShadowJar(type: ShadowJar) {
    zip64 true
    from './build/classes/java/main'
    from project.configurations.compile
    from './src/dev/resources' // or wherever the resources and up under ./build
}