snowe
04/26/2019, 7:44 PMinit.gradle
script? I'm trying to reference a property using by project
but I get the error message Line 1: val ptSnapshotsReaderPassword: String by project
^ Function invocation 'project(...)' expected
eskatos
04/26/2019, 8:11 PM*.init.gradle.kts
to use the Gradle Kotlin DSLsnowe
04/26/2019, 8:13 PM*.
?init.gradle.kts
eskatos
04/26/2019, 8:25 PM.gradle.kts
extension*.init.gradle.kts
will make the IDEs understand that it is an “initialization script” and provide you with the right set of APIs*.gradle.kts
... I got confused because your original message says the file is named init.gradle
snowe
04/26/2019, 8:27 PMinit.gradle
script. or initialization script.init.gradle
to init.gradle.kts
and am getting the above errors.eskatos
04/26/2019, 8:28 PMproject
is not available in an init script, an init script is evaluated against the Gradle
instance, the available api is not Project
See https://docs.gradle.org/current/userguide/init_scripts.htmlsnowe
04/26/2019, 8:29 PM~/.gradle/gradle.properties
is not a project level properties.init.gradle
file, but not when I change it to kotlinby project
. I'm really asking how to retrieve the properties from ~/.gradle/gradle.properties
within an init.gradle.kts
file. I don't really care how it's done.eskatos
04/26/2019, 8:35 PMby settings
or by project
in an init script but you need to do that in a block that provides access to settings/projectgradle.settingsEvaluated {
val myProperty: String? by settings
println("From settings $myProperty")
}
gradle.rootProject {
val myProperty: String? by project
println("From root project $myProperty")
}
snowe
04/26/2019, 8:38 PMsettingsEvaluated {
val ptSnapshotsReaderPassword: String? by settings
settings.pluginManagement {
repositories {
// if (findProperty("mavenLocal") != null) { mavenLocal() }
gradlePluginPortal()
jcenter()
maven {
credentials {
username = "pt-snapshots-reader"
password = ptSnapshotsReaderPassword
}
}
}
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "net.researchgate") {
useModule("net.researchgate:gradle-release:3.0.0-RC3")
}
}
}
}
}
findProperty
block to work...eskatos
04/26/2019, 8:38 PMsettings.pluginManagement {
to just pluginManagement {
snowe
04/26/2019, 8:40 PMsettings
.eskatos
04/26/2019, 8:40 PMsnowe
04/26/2019, 8:40 PMsettingsEvaluated {
val ptSnapshotsReaderPassword: String? by settings
val mavenLocal: Boolean? by settings
pluginManagement {
repositories {
if (mavenLocal != null) { mavenLocal() }
gradlePluginPortal()
jcenter()
maven {
credentials {
username = "pt-snapshots-reader"
password = ptSnapshotsReaderPassword
}
url = uri("")
}
}
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "net.researchgate") {
useModule("net.researchgate:gradle-release:3.0.0-RC3")
}
}
}
}
}
eskatos
04/26/2019, 8:41 PM