following on from the message above, I have a vers...
# gradle
f
following on from the message above, I have a versions catalog where I define the dependencies - is it possible to use that in the
buildSrc/build.gradle.kts
? Details in thread
current file
Copy code
plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}

repositories {
    mavenCentral()
    google()
}

dependencies {
    implementation("com.android.tools.build:gradle:7.3.0-alpha07")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
}
intended solution (doesn't build)
Copy code
plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}

repositories {
    mavenCentral()
    google()
}

dependencies {
    implementation(libs.com.android.tools.build.gradle)
    implementation(libs.org.jetbrains.kotlin.kotlin.gradle.plugin)
}
e
https://github.com/gradle/gradle/issues/15383 basically plugins cannot assume that they'll be running in a build with the same version catalog, so you have to use the non-typesafe API
f
thanks for the link, I'll look into that workaround
v
That answer does not really fit the question, as you try to use the version catalog in the build script of the plugin build, not within the precompiled script plugin. Just define the version catalog with the path to the toml file in the settings script of the plugin build.
f
thanks, I tried that, but then
libs
is not recognized in the build script, this is my
settings.gradle.kts
in
buildSrc
Copy code
dependencyResolutionManagement {
    versionCatalogs {
        lib {
            from(files("../gradle/libs.versions.toml"))
        }
    }
}
v
well, if you define a version catalog called "lib" how can you expect it to be available under the name "libs"? 😉
f
yes, sorry, it was a typo, it's called
libs
everywhere
this is the
build.gradle.kts
file
Copy code
plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}

repositories {
    mavenCentral()
    google()
}

dependencies {
    implementation(libs.com.android.tools.build.gradle)
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
    implementation("com.google.dagger:hilt-android-gradle-plugin:2.41")
}
v
Why do you try to confuse me? 😞 It does not complain that it does not find
libs
in the build script. It complains that it does not find
libs
in the settings script.
Replace
libs {
by
create("libs") {
and it should work fine
f
thanks for your help. That didn't make a difference unfortunately
Copy code
dependencyResolutionManagement {
    versionCatalogs {
        create("libs") {
            from(files("./../../gradle/libs.versions.toml"))
        }
    }
}
and
Copy code
plugins {
    `kotlin-dsl`
    `kotlin-dsl-precompiled-script-plugins`
}

repositories {
    mavenCentral()
    google()
}

dependencies {
    implementation(libs.com.android.tools.build.gradle)
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
    implementation("com.google.dagger:hilt-android-gradle-plugin:2.41")
}
libs
is not recognized
v
Then you need to provide an MCVE, it works fine here
f
v
message has been deleted
🤦‍♂️ 1
f
yup, it works when you place things in the right place, thanks, much appreciated!
👌 1
aren't we threaded already?
v
Sorry, misclicked
f
I see the IDE doesn't have support for this though, it shows all red, but it compiles fine
v
No, should work fine after you synced
Only plugins from version catalogs don't work properly iirc
Or well, sometimes in some places it works, sometimes not. The support is partly still a bit flaky
f
after syncing it's still red, but I'm not concerned about this as it works fine
👌 1