I receive an error reading a property with dot notation from gradle.properties
. Why?
If I use version
instead of build.version
everything is OK.
Thanks in advance.
gradle.properties
build.version=2.0.1
build.gradle
apply plugin: 'java'
task testProperties << {
println "***************** TEST **********************"
println build.version
println "*********************************************"
}
... $ gradle devTest
:devTest
***************** TEST **********************
:devTest FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '..../build.gradle' line: 50
* What went wrong:
Execution failed for task ':devTest'.
> Could not find property 'version' on task ':build'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or<br> --debug option to get more log output.
BUILD FAILED
gradle.properties
version=2.0.1
build.gradle
apply plugin: 'java'
task testProperties << {
println "***************** TEST **********************"
println version
println "*********************************************"
}
... $ gradle devTest
:devTest
***************** TEST **********************
2.0.1
*********************************************
BUILD SUCCESSFUL
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.
Click on Environment variables. After that, click the New option. Now, create user variable, enter the variable name as Gradle_Home and paste the value of the home path e.g., C:\gradle-6.0. 1 in the variable value field.
You cannot use properties with a dot in this way because Groovy thinks it's a version
property of the build
instance. If you want a property to contain a dot then you should use it in the following way:
println rootProject.properties['build.version']
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