https://kotlinlang.org logo
Title
i

Ido Flax

01/26/2023, 7:15 AM
I want to create a plugin that applies the shadow jar plugin and configures it, but i can’t figure out how to add shadowJar as a dependency to the plugin, I tried:
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
But i can’t reference ShadowJar class in my main plugin (binary) code Any advice?
g

gildor

01/26/2023, 7:19 AM
It should work, right
Are you sure that your Gradle sync finished successfully? (for example you may have no gradlePluginPortal() in repositories)
i

Ido Flax

01/26/2023, 4:26 PM
Yeah i’m sure.
a

Adam S

01/26/2023, 4:33 PM
I think that the Shadow plugin is written in Groovy, so unless the
ShadowJar
class is compiled as static then it’s tough to use it from Kotlin or Java there’s an overview of Groovy/Kotlin interop here: https://docs.gradle.org/current/userguide/kotlin_dsl.html#sec:interoperability
g

gildor

01/26/2023, 4:58 PM
Just tried and it works as dependency for Kotlin Gradle Plugin, no problem, so it's not an issue of Groovy compatibility, otherwise it wouldn't work with Java and with Kotlin DSL