Hey everyone, I am working on kmp project and want...
# gradle
r
Hey everyone, I am working on kmp project and want to create a custom gradle convention plugin for setting up compose multiplatform UI testing. But I don't know how to add below dependencies because we cannot directly reference the
compose.uiTest
or
compose.desktop.currentOs
. Any ideas how to do that??
Copy code
commonTest.dependencies {
            @OptIn(ExperimentalComposeLibrary::class)
            implementation(compose.uiTest)
        }

        desktopTest.dependencies {
            implementation(compose.desktop.currentOs)
        }
v
What do you mean with you "cannot directly reference" them? Do you have a version catalog named
compose
where those are defined?
r
No, we don't have to reference in the version catalog.
compose.uiTest
is directly referenced from the
build.gradle.kts
file. I found that here in this documentation I just need to know the complete dependency string to which compose.uiTest is referring to.
v
No, not in your version catalog that you most probably named "libs", that would be "libs...". As there "compose..." is used, it expects that you declared a version catalog named "compose". Most probably they publish a version catalog that you can consume in your build.
It speaks about a project generated from their generator, I guess there the catalog is defined
r
Hmmm, you're right. How can we access that version catalog?
v
Ask them (#CJLTWPH7S), or check the project you generated when following that tutorial. It should be defined in the settings script.
r
Okay, thanks for your help @Vampire
v
Or their plugins add such accessors, as I don't see a version catalog in their generated project
e
yes. the jb compose gradle plugin defines the
compose
extension and provides those accessors
r
Ohh, so can is there any way to find out the complete dependency string @ephemient?
e
if you're writing a script plugin you should be able to apply the compose plugin like any other, and get access to its accessors
r
e
if you're writing a regular plugin then do the usual thing to access extensions
r
I'm really unaware about that. Could you please suggest me some resources or docs where I can get the idea how to do it?
v
If you really want to know the coordinates, you can also simply navigate to the accessors in your IDE
Copy code
@NotNull
public final String getRuntime() {
   return ComposePluginKt.access$composeDependency("org.jetbrains.compose.runtime:runtime");
}

@NotNull
public final String getRuntimeSaveable() {
   return ComposePluginKt.access$composeDependency("org.jetbrains.compose.runtime:runtime-saveable");
}
...
r
Thanks @Vampire I found this which refers to actual dependency strings.
👌 1
p
project.extensions.getByType(ComposeExtension::class.java).dependencies
e
Copy code
val compose: ComposeExtension by project.extensions
compose.dependencies.…
is what I would do but that works