I'm implementing a custom plugin to add some depen...
# plugin-development
e
I'm implementing a custom plugin to add some dependencies. I'm using
project.dependencies.add
to add them. The issue is that I need to set some
excludes
for these dependencies. I tried to use a lambda after the
add
, but it didn't work. Is there a way to add these excludes?
t
Which language are you using? With Groovy that should Just Work™. With Kotlin it could work if you
import org.gradle.kotli.dsl.add
. In Java you'd have to call the
add(String,Object)
overload and cast the return value to
ModuleDependency
(it'll likely be an
ExternalModuleDependency
) to call its
exclude(Map<String,String>)
method.
e
Kotlin. The AS didn't suggest the import. Putting manually works. Thanks a lot.
👌 1
t
Fwiw, I
import org.gradle.kotli.dsl.*
(yep, wildcard, the only one I'm allowing myself to use) so I can write my Kotlin code almost as if it was a Gradle Kotlin DSL script.
🤯 1
v
Maybe with the missing
n
. 😄 For me the IDE usually suggests also those imports. 🤷‍♂️