Hi there, how can a script plugin access a class t...
# gradle
j
Hi there, how can a script plugin access a class that is defined in another plugin? eg.
Copy code
build.gradle.kts
plugins {
id("a")
}

apply(from = "b.gradle.kts")
---------------
b.gradle.kts

val c = A() //A is a class defined in plugin "a" and how do I make it accessible here?
g
Only by applying plugin A again
Otherwise there is no way to know about this class in B
You also can put this class to buildSrc/src/main/kotlin it will make it accessible from all projects and files of your project
j
buildSrc works, but that's a last resort to me due to other reasons. I also tried with
apply(plugin = "a")
in b, but it didn't want to work. but let me try again.
unfortunately, not working. can't even find the class to import.
tried
plugins{ id("a") }
too and gradle did not like it either
g
I need more context, a lot of things may be wrong and “unfortunately, not working” is not enough information
Did you read official migration guide for Kotlin DSL? They have a lot of examples and explanations how things work
j
Copy code
Line 01: import com.abc.A
                      ^ Unresolved reference: abc
is the message
line 2
apply(plugin="a")
adding a buildscript dependencies block works though
g
It still not enough
maybe you have some self contained example
j
it's a part of a complex work project, and i'll probably just live with the buildscript. thanks for your help!
d
I have hacked something similar by <ugly> sticking into a project level extension variable and using only basic types (Map<String,String>), some casts and a prayer
😎 1