我在gradle.properties中有这个常数。
VERSION_NAME=0.1.0
我希望能够在Kotlin文件(一个数据类)中使用这个值。类似于试图从System.getProperty("VERSION_NAME")中删除它。
这是数据类所在模块上的build.gradle.kts(Kotlin DSL)
plugins {
    id("java-library")
    id("org.jetbrains.kotlin.jvm")
    id("com.vanniktech.maven.publish")
}
java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}
dependencies {
    implementation(Dependencies.Squareup.Retrofit2.retrofit)
    implementation(Dependencies.Squareup.Retrofit2.converterGson)
    implementation(Dependencies.Squareup.Okhttp3.okhttp)
    implementation(Dependencies.Squareup.Okhttp3.loggingInterceptor)
    implementation(Dependencies.Google.Code.gson)
}
我更熟悉Android,那里有BuildConfig静态常量。然而,由于这不是一个Android项目,我需要以不同的方式获得价值。
我试图了解如何在kotlin代码中获取“gradle.properties”中定义的自定义属性?这与我所需要的非常相似,只是tasks.named<JavaExec>("run")...不起作用,因为在项目中找不到“运行”任务。
我对这些类型的Kotlin项目和一般的gradle很陌生,所以我迷路了。