I want to have one thick jar, but without the dependencies provided. Therefore, I use the following two plugins:
and create the build.gradle file as follows:
apply plugin: 'nebula.provided-base' apply plugin: 'com.github.johnrengelman.shadow' archivesBaseName = 'range-cache-drivers' group = 'com.engine' version = '0.302-SNAPSHOT' buildDir = 'target' sourceCompatibility = 1.8 targetCompatibility = 1.8 dependencies { provided project(':rangeCache')
But when I run gradle shadowJar , I still have all rangeCache classes in my thick jar. How can I exclude the provided dependencies from my thick jar?
EDIT 1: This also does not work, transient dependencies are still copied to the fat jar.
shadowJar { dependencies { exclude(project(':rangeCache')) } }
EDIT 2: Based on Stanislav's answer, I did the following for proper operation:
configurations { shadow compile.extendsFrom provided provided.extendsFrom shadow } dependencies { provided project(':rangeCache') // CSV, TSV, Fixe width shadow deps.univocityParsers // MongoDB shadow deps.mongo // Cassandra shadow deps.cassandradx shadow deps.cassandraSnappy shadow deps.cassandraLZ4 testCompile deps.junit } import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar task fatJar(type: ShadowJar) { configurations = [project.configurations.shadow] from(project.sourceSets.main.output) }
source share