All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jengelman.gradle.plugins.shadow.ShadowPlugin.kt Maven / Gradle / Ivy

Go to download

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.

There is a newer version: 9.0.0-beta4
Show newest version
package com.github.jengelman.gradle.plugins.shadow

import com.github.jengelman.gradle.plugins.shadow.legacy.LegacyShadowPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.api.plugins.JavaPlugin

public abstract class ShadowPlugin : Plugin {

  override fun apply(project: Project) {
    project.run {
      plugins.apply(ShadowBasePlugin::class.java)
      @Suppress("WithTypeWithoutConfigureEach")
      plugins.withType(JavaPlugin::class.java) {
        plugins.apply(ShadowJavaPlugin::class.java)
      }
      @Suppress("WithTypeWithoutConfigureEach")
      plugins.withType(ApplicationPlugin::class.java) {
        plugins.apply(ShadowApplicationPlugin::class.java)
      }
      // Apply the legacy plugin last
      // Because we apply the ShadowJavaPlugin/ShadowApplication plugin in a withType callback for the
      // respective JavaPlugin/ApplicationPlugin, it may still apply before the shadowJar task is created etc.
      // If the user applies shadow before those plugins. However, this is fine, because this was also
      // the behavior with the old plugin when applying in that order.
      plugins.apply(LegacyShadowPlugin::class.java)
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy