gradle-shadow-jar

Palantir open source project

License

License

Categories

Categories

Gradle Build Tools Ant
GroupId

GroupId

com.palantir.gradle.shadow-jar
ArtifactId

ArtifactId

gradle-shadow-jar
Last Version

Last Version

88eab43
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

gradle-shadow-jar
Palantir open source project
Project URL

Project URL

https://github.com/palantir/gradle-shadow-jar
Project Organization

Project Organization

Palantir Technologies Inc
Source Code Management

Source Code Management

https://github.com/palantir/gradle-shadow-jar

Download gradle-shadow-jar

Dependencies

runtime (2)

Group / Artifact Type Version
com.github.jengelman.gradle.plugins » shadow jar 5.2.0
com.google.guava : guava jar 28.2-jre

Project Modules

There are no modules declared in this project.

Autorelease

Gradle shadow jar Bintray License

This is a Gradle plugin that wraps the existing shadow Gradle plugin to make producing partially shaded jars much easier. This means you can shade just one of your dependencies in a library or Gradle plugin to avoid dependency clashes. It is possible to produce fully shaded jars with this plugin, but it is not the aim of this plugin, and perf may be bad for shading a large dependency tree.

Applying the plugin

To apply this plugin, build.gradle should look something like:

 buildscript {
     repositories {
         maven { url 'https://dl.bintray.com/palantir/releases' }
     }
 
     dependencies {
         classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:<version>'
+        classpath 'com.palantir.gradle.shadow-jar:gradle-shadow-jar:<version>'
     }
     
     apply plugin: 'com.palantir.consistent-versions'
+    apply plugin: 'com.palantir.shadow-jar'
 }

Requires gradle-consistent-versions and Gradle 6 to work.

Producing shaded JARs

Shading is where you copy the class files of another jar into your jar, and then change the package names of the classes from the original jar. This removes dependencies from your project's publication and can reduce dependency conflicts at the expense of increased jar size and build time.

To use, identify which of your dependencies you want shaded and put them in the shadeTransitively configuration like so:

dependencies {
    implementation 'some-unshaded:dependency'

    shadeTransitively 'com.google.guava:guava'
}

The dependency you list and all its dependencies will be shaded unless one of these dependencies exists in other standard java configurations. For example, com.google.guava:guava:28.2-jre depends on 'com.google.code.findbugs:jsr305:3.0.2'. If you use the following:

dependencies {
    implementation 'com.google.code.findbugs:jsr305'

    shadeTransitively 'com.google.guava:guava'
}

will shade guava and all its dependencies except for jsr305 (and its dependencies), which will not be shaded and appear in the maven POM.

We explicitly ban logging libraries from shading, as they can cause problems when shaded, and will show up as real dependencies in your POM, even if they were brought in as transitives through shadeTransitively.

com.palantir.gradle.shadow-jar

Palantir Technologies

Versions

Version
88eab43
2.5.0
2.4.0
2.3.0
2.2.0
2.1.0
2.0.0
1.4.0
1.3.2
1.3.1
1.3.0
1.2.0
1.1.0
1.0.3