Skip to content

ConfigureShadowRelocation with Kotlin DSL #629

@2x2xplz

Description

@2x2xplz

I feel pretty dumb for converting my Gradle scripts to the Kotlin DSL because, despite writing my program in Kotlin, the Gradle DSL is entirely un-intuitive and has very little documentation, the whole thing has caused headaches with no benefit.

With that said, how would one use the ConfigureShadowRelocation task in a Kotlin DSL gradle script?

I currently have this working:

tasks {
    named<ShadowJar>("shadowJar") {
      ...definition here...
    }
}

tasks {
    build {
        dependsOn(shadowJar)
    }
}

I tried:

tasks {
    "relocateShadowJar"(ConfigureShadowRelocation::class) {
        target = shadowJar.get()
        prefix = "myprefix"
    }
}

and

tasks {
    named<ConfigureShadowRelocation>("configureShadowRelocation") {
        target = shadowJar.get()
        prefix = "myprefix"
    }
}

but cannot create a valid dependency relationship:

tasks {
    shadowJar {
        dependsOn(configureShadowRelocation)  <--- unresolved
        dependsOn(relocateShadowJar)  <--- unresolved
    }
}

I'm not sure this will even work, I am able to create a single working JAR from 3 individual package components (thank you!). I wanted to relocate the 3 packages to keep them together and distinct from all of the 3rd party dependencies, but this caused ClassNotFoundExceptions, I am hoping to fix these with the ConfigureShadowRelocation plugin. In other words I want to change:

com
javax
aaa
bbb
ccc
net
org

to

com
javax
myprogram
  |
  |\_aaa
  |\_bbb
   \_ccc
net
org

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions