Is there a maven shade plugin equivalent in gradle?

Hello,

I need to create a fat jar but also need to relocate the included classes from the jars in order to create a private copy of their bytecode in gradle and was wondering if this is possible at all at the moment, Maven supports this through the Shade plugin (http://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html) which does this pretty well.

Is there a solution for this in Gradle?

Thanks,

Zahid

You can use the JarJar ant task after creating the jar using the fatJar plugin.

configurations {
  tools
}
  dependencies {
  tools "org.elasticsearch:es-jarjar:1.0.0"
}
jar << {
  jarjarArchivePath = new File(jar.archivePath.absolutePath + ".jarjar.jar")
  project.ant {
    taskdef name: "jarjar", classname: "com.tonicsystems.jarjar.JarJarTask", classpath: configurations.tools.asPath
    jarjar(jarfile: jarjarArchivePath, filesetmanifest: "merge", manifest:"src/main/resources/MANIFEST.MF") {
      zipfileset(src: jar.archivePath)
      configurations.runtime.files.findAll {file ->
        ['gson'].any { file.name.contains(it) }
      }
        rule pattern: "com.google.gson.**", result: "com.foobar.repacked.gson.@1"
    }
    delete(file: jar.archivePath)
    copy(file: jarjarArchivePath, tofile: jar.archivePath)
    delete(file: jarjarArchivePath)
}

You can check out the new Shadow plugin: http://forums.gradle.org/gradle/topics/announcing_gradle_shadow_plugin_maven_shade_port

Or on Github: https://github.com/johnrengelman/shadow

Does this work without farJar?