Package com.ljarocki.shadedjar
Class ShadedJarExtension
java.lang.Object
com.ljarocki.shadedjar.ShadedJarExtension
DSL for the plugin:
shadedJar {
mainClass = 'com.example.Main'
archiveClassifier = 'all'
relocate 'com.google.common', 'com.example.shaded.guava' // optional
relocate 'org.apache.commons', 'com.example.shaded.commons', {
exclude 'org.apache.commons.logging.**' // scoped to a subset — optional
}
}
With no relocate(...) rules the task builds a plain fat JAR; adding one
or more rules turns it into a shaded JAR (packages rewritten). The presence of
rules is the only switch — there is no separate boolean.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.provider.Property<String> Filename classifier for the fat jar (defaultall).abstract org.gradle.api.provider.Property<String> Main-Classwritten into the fat jar's manifest.abstract org.gradle.api.provider.Property<Boolean> Whentrue, drops any bundled dependency class the reachability analysis can't prove is used by the project's own code (seeMinimizer).abstract org.gradle.api.provider.SetProperty<String> Classes never dropped byminimize()regardless of reachability (seeMinimizeSpec.keep(java.lang.String...)); exact dotted name or a.**prefix wildcard, same pattern language as relocation's include/exclude.Exclude patterns per relocation, same shape asgetRelocationIncludes().Include patterns per relocation, keyed by the samefromprefix asgetRelocations(); comma-separated.Package relocations: source dotted prefix -> shaded dotted prefix.voidminimize()DSL sugar:minimize()turns on dead-class stripping with no keep exceptions.voidminimize(org.gradle.api.Action<? super MinimizeSpec> configure) DSL sugar with a scoping block:minimize { keep '...' }.voidDSL sugar:relocate 'com.google.common', 'shaded.guava'.voidrelocate(String pattern, String destination, org.gradle.api.Action<? super RelocationSpec> configure) DSL sugar with a scoping block:relocate 'from', 'to', { exclude '...' }.
-
Constructor Details
-
ShadedJarExtension
public ShadedJarExtension()
-
-
Method Details
-
getMainClass
Main-Classwritten into the fat jar's manifest. -
getArchiveClassifier
Filename classifier for the fat jar (defaultall). -
getRelocations
Package relocations: source dotted prefix -> shaded dotted prefix. -
getRelocationIncludes
Include patterns per relocation, keyed by the samefromprefix asgetRelocations(); comma-separated. SeeRelocationSpec. -
getRelocationExcludes
Exclude patterns per relocation, same shape asgetRelocationIncludes(). -
getMinimize
Whentrue, drops any bundled dependency class the reachability analysis can't prove is used by the project's own code (seeMinimizer). Defaultfalse— no class is ever dropped unless this is turned on. -
getMinimizeKeep
Classes never dropped byminimize()regardless of reachability (seeMinimizeSpec.keep(java.lang.String...)); exact dotted name or a.**prefix wildcard, same pattern language as relocation's include/exclude. -
minimize
public void minimize()DSL sugar:minimize()turns on dead-class stripping with no keep exceptions. -
minimize
DSL sugar with a scoping block:minimize { keep '...' }. SeeMinimizeSpec. -
relocate
DSL sugar:relocate 'com.google.common', 'shaded.guava'. -
relocate
public void relocate(String pattern, String destination, org.gradle.api.Action<? super RelocationSpec> configure) DSL sugar with a scoping block:relocate 'from', 'to', { exclude '...' }. SeeRelocationSpec.
-