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.69k stars 389 forks source link

Is the shadow plugin supposed to use the distributions spec? #290

Open javadevmtl opened 7 years ago

javadevmtl commented 7 years ago

Please check the (User Guide)[http://imperceptiblethoughts.com/shadow] before submitting "how do I do 'x'?" questions!

Shadow Version

1.2.4

Gradle Version

3.4

Expected Behavior

When running installShadow, distShadowZip/Tar I would like to copy some extra folders to the distribution folders using:

distributions {
  main {
    contents {
      from('src/main') {
        include 'conf/**'
      }
    }
  }
}

This only works with the base install dist tasks of gradle.

Actual Behavior

It's ignored and only this seems to work:

installShadowApp {
  distributions {
    contents {
      from('src/main') {
        include 'conf/**'
      }
      from ('.') {
        include 'webroot/**'
      }
    }
  }
}

Gradle Build Script(s)

plugins {
  id 'idea'
  id 'java'
  id 'application'
  id 'distribution'
  id 'com.github.johnrengelman.shadow' version '1.2.4'
}

repositories {
  jcenter()
  maven {
    url "https://oss.sonatype.org/content/repositories/snapshots/"
  }
}

sourceCompatibility = '1.8'

dependencies {
  compile 'io.vertx:vertx-core:3.4.1'
  compile 'io.vertx:vertx-web:3.4.1' 
}

mainClassName = 'io.vertx.core.Launcher'

shadowJar {
  classifier = 'fat'

  manifest {
    attributes 'Main-Verticle': 'xxxx'
  }

  mergeServiceFiles {
    include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
  }
}

installShadowApp {
  distributions {
    contents {
      from('src/main') {
        include 'conf/**'
      }
      from ('.') {
        include 'webroot/**'
      }
    }
  }
}

// Doesn't work with installShadow and distShadowZip
//distributions {
//  main {
//    contents {
//      from('src/main') {
//        include 'conf/**'
//      }
//    }
//  }
//}

Content of Shadow JAR (jar tf <jar file> - post link to GIST if too long)

karottenreibe commented 6 years ago

It seems that the workaround with installShadowApp{} no longer works. I couldn't figure out any way to include additional files in the shadow dist

karottenreibe commented 6 years ago

After looking at the source code, it seems that instead of distributions { main {...} } you need to use distributions { shadow {...} }. This works for me. Probably the documentation just needs to reflect this as it's not obvious at all ATM

johnrengelman commented 6 years ago

Pull requests welcome

karottenreibe commented 6 years ago

Not sure where the docs are in this repo? Couldn't find them

johnrengelman commented 6 years ago

https://github.com/johnrengelman/shadow/tree/master/src/docs/asciidoc