I can't find the syntax of property interpolation in gradle.properties:
prop1 = value
prop2 =${prop1}/lib
Is it supported at all ? Thanks
Using the -D command-line option, you can pass a system property to the JVM which runs Gradle. The -D option of the gradle command has the same effect as the -D option of the java command. You can also set system properties in gradle. properties files with the prefix systemProp.
Last Updated on April 3, 2022. Gradle project properties provide an easy way to customise builds which may need to run differently in certain situations. In this article you'll learn the most effective ways to use and set properties, along with some common scenarios you might come across in your Gradle project.
Defining properties via system properties We use the -D command-line option just like in a normal Java application. The name of the system property must start with org. gradle. project , followed by the name of the property we want to set, and then by the value.
gradle.properties
is a plain Java properties files, hence String interpolation isn't supported. I recommend to keep all user-defined properties in build.gradle
or a separate build script, which provide a much richer configuration language. For example:
gradle/properties.gradle:
ext {
foo = "foo"
foobar = "${foo}bar".toUpperCase()
}
build.gradle:
apply from: "gradle/properties.gradle"
println foobar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With