Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

buildSrc Version script object not being added root buildScript or any project context

i have a simple buildSrc configuration for dependency versions

a buildSrc/gradle.build.kts:

repositories {
    jcenter()
}

plugins {
    `kotlin-dsl`
}

dependencies {
    implementation(kotlin("script-runtime"))
}

I would like to point out that my kotlin script wouldnt work at all without the script-runtime dependency and I have never seen any documentation saying its required but once i added it an error went away:

"No script runtime was found in the classpath: class 'kotlin.script.templates.standard.ScriptTemplateWithArgs' not found. Please add kotlin-script-runtime.jar to the module dependencies."

Then i have a simple object script buildSrc/src/main/java/Versions.kts

object Versions {
    val kotlin = "1.3.61"
    val kotlinFrontentPlugin = "0.0.45"
}

Doesnt get much simpler.

Then in my root project i have: build.gradle.kts:

buildscript {

    repositories {
        google()
        mavenCentral()
        jcenter()
        maven("https://plugins.gradle.org/m2/")
        maven("https://dl.bintray.com/kotlin/kotlin-eap")
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
        classpath("org.jetbrains.kotlin:kotlin-frontend-plugin:${Versions.kotlinFrontendPlugin}")
    }
}

This is all just straight up copy and paste. but all i can get is:

Line 12: classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}") ^ Unresolved reference: kotlin

Line 13: classpath("org.jetbrains.kotlin:kotlin-frontend-plugin:${Versions.kotlinFrontendPlugin}") ^ Unresolved reference: kotlinFrontendPlugin

Does buildSrc just no longer work in builds anymore or is there yet some other undocumented setting or action i need to take?

like image 747
Will Avatar asked Oct 12 '25 13:10

Will


1 Answers

Found the issue. I accidentally named my object as a script Versions.kts when it needed to be Versions.kt

like image 70
Will Avatar answered Oct 14 '25 15:10

Will