Is it possible to relocate all packages excluding the only one without specifying all

304 Views Asked by At

As I can see ConfigureShadowRelocation task does not support excludes. ShadowJar task does not support patterns in relocate method. I use version 7.1.2.

Is there a way to do a bulk relocation with excludes? Maybe I missed something.

UPD: Here is an example:

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
    id("com.github.johnrengelman.shadow") version "7.1.2"
}

dependencies {
    implementation(project(":lib-b"))

    implementation("com.squareup.okhttp3:okhttp:4.10.0")
}

tasks.withType<ShadowJar> {
    archiveClassifier.set("")
    relocate("my.example", "shaded.example") {
        exclude("my.example.api.*")
    }
    relocate("okhttp3", "shaded.okhttp3")
    relocate("com.fasterxml.jackson", "shaded.jackson")
}

In the example lib-b brings the only transitive dependency com.fasterxml.jackson. But in a real scenario there might be lots of them. I wonder if there is a way not to specify them all in relocate method.

0

There are 0 best solutions below