GradleUp / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
https://www.gradleup.com/shadow/
Apache License 2.0
3.76k stars 395 forks source link

Discussion on configuration modifications before starting pull request #132

Open rspieldenner opened 9 years ago

rspieldenner commented 9 years ago

We're looking at shading portions of our internal libraries and only publishing these shaded artifacts. Instead of both the normal jar and the shaded/shadow jar.

We'd like to simplify how the plugin would define that behavior and figure out if that should go into the shadow plugin proper or us creating a wrapper around it.

So for this example lets consider 2 dependencies example:a and example:b. example:a occurs in the api and can't be shaded. example:b can be shaded.

We'd like to do something like the following

// normal setup
group = 'rob.project'

dependencies {
  compile 'example:a:1.0.0'
  shaded 'example:b:1.0.0'
}

compile would be kept in the runtime of the pom

everything in shaded (or shadow if you want to change that) would be shaded into the jar, and would automatically be shaded to rob.project.example.*

replacing the normal jar with the shaded jar is pretty easy with current gradle

jar.deleteAllActions()
shadowJar {
  classifier = ''
}
jar.dependsOn shadowJar

Do you think you want to take this plugin in that direction? Or should we create a wrapper.

johnrengelman commented 9 years ago

This is already supported, but you have the notation backwards.

dependencies {
  compile 'example:b:1.0.0'
  shadow 'example:a:1.0.0'
}

tasks.withType(AbstractCompile) {
  classpath += configurations.shadow //adds the shadow jars to the classpath so you don't have to declare them twice
}

publishing {
  publications {
    main(MavenArtifact) {
      from(components.shadow) {
        classifier = ''
      }
    }
  }
}