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.75k stars 396 forks source link

Relocate doesn't relocate services #291

Open BrainStone opened 7 years ago

BrainStone commented 7 years ago

Shadow Version

1.2.4

Gradle Version

3.5

Expected Behavior

The class(es) referenced in the service file(s) should be relocated when the orginal class gets relocated

Actual Behavior

The class(es) referenced in the service file(s) do not get renamed/relocated.

Gradle Build Script(s)

plugins {
    id "com.github.johnrengelman.shadow" version "1.2.4"
}

repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    compile "mysql:mysql-connector-java:6.0.6"
}

shadowJar {
    classifier = null

    dependencies {
        include dependency("mysql:mysql-connector-java")
    }

    relocate "com.mysql", "com.example.proj.shadow.mysql"
}

Content of Shadow JAR (shortened)

META-INF/MANIFEST.MF
META-INF/
META-INF/services/
META-INF/services/java.sql.Driver    # contians: com.mysql.cj.jdbc.Driver
com/
com/example/
com/example/proj/
com/example/proj/...
com/example/proj/shadow/
com/example/proj/shadow/mysql/
com/example/proj/shadow/mysql/cj/
com/example/proj/shadow/mysql/cj/...
com/example/proj/shadow/mysql/cj/jdbc/
com/example/proj/shadow/mysql/cj/jdbc/...
com/example/proj/shadow/mysql/cj/jdbc/Driver.class
com/example/proj/shadow/mysql/cj/jdbc/...
com/example/proj/shadow/mysql/cj/...
com/example/proj/shadow/mysql/jdbc/
com/example/proj/shadow/mysql/jdbc/...
tylerbenson commented 7 years ago

Any ideas for a work around for this?

cjstehno commented 7 years ago

The services relocated properly for me when I added the service merge transformer. The documentation is a bit weak but it merged and relocated them. Not sure if this fixes your issue.