Class ShadedJarExtension

java.lang.Object
com.ljarocki.shadedjar.ShadedJarExtension

public abstract class ShadedJarExtension extends Object
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 Details

    • ShadedJarExtension

      public ShadedJarExtension()
  • Method Details

    • getMainClass

      public abstract org.gradle.api.provider.Property<String> getMainClass()
      Main-Class written into the fat jar's manifest.
    • getArchiveClassifier

      public abstract org.gradle.api.provider.Property<String> getArchiveClassifier()
      Filename classifier for the fat jar (default all).
    • getRelocations

      public abstract org.gradle.api.provider.MapProperty<String,String> getRelocations()
      Package relocations: source dotted prefix -> shaded dotted prefix.
    • getRelocationIncludes

      public abstract org.gradle.api.provider.MapProperty<String,String> getRelocationIncludes()
      Include patterns per relocation, keyed by the same from prefix as getRelocations(); comma-separated. See RelocationSpec.
    • getRelocationExcludes

      public abstract org.gradle.api.provider.MapProperty<String,String> getRelocationExcludes()
      Exclude patterns per relocation, same shape as getRelocationIncludes().
    • getMinimize

      public abstract org.gradle.api.provider.Property<Boolean> getMinimize()
      When true, drops any bundled dependency class the reachability analysis can't prove is used by the project's own code (see Minimizer). Default false — no class is ever dropped unless this is turned on.
    • getMinimizeKeep

      public abstract org.gradle.api.provider.SetProperty<String> getMinimizeKeep()
      Classes never dropped by minimize() regardless of reachability (see MinimizeSpec.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

      public void minimize(org.gradle.api.Action<? super MinimizeSpec> configure)
      DSL sugar with a scoping block: minimize { keep '...' }. See MinimizeSpec.
    • relocate

      public void relocate(String pattern, String destination)
      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 '...' }. See RelocationSpec.