Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle ShadowJar with Other SourceSet Resources

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.

like image 278
anthonylawson Avatar asked Oct 19 '25 06:10

anthonylawson


1 Answers

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
}
like image 88
Sergii Redchuk Avatar answered Oct 22 '25 05:10

Sergii Redchuk