gradle.properties fail reading property with dot notation

gradle.properties fail reading property with dot notation

gradle project properties
gradle set system property
gradle global properties
gradle set environment variable
gradle build different environments
gradle environment variable
gradle maxmetaspacesize
gradle_opts

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.

FAIL CASE

gradle.properties

build.version=2.0.1

build.gradle

apply plugin: 'java'

task testProperties << {
    println "***************** TEST **********************"
    println build.version
    println "*********************************************"
}
EXECUTION
... $ 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
SUCCES CASE

gradle.properties

version=2.0.1

build.gradle

apply plugin: 'java'

task testProperties << {
    println "***************** TEST **********************"
    println version
    println "*********************************************"
}
EXECUTION
... $ gradle devTest

:devTest

***************** TEST **********************
2.0.1

*********************************************

BUILD SUCCESSFUL

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']

Allowing the user to define properties with a dot in , Hello, It is quite a common idiom that, when you have properties related to one for it (I have tried sourcing a 'gradle.properties' with such values but failed). for that type of definitions to be usable from property files, or from 'project.ext'? The following example shows the pattern to initialize a project property with a default value, and thus preventing build failure if the property was not declared externally on command line or gradle.properties files. For more details on how to declare project properties in the build scripts, see Extra Properties.


Another way to get access to the properties is using syntax below

println "Version: ${project.'build.version'}"

gradle.properties fail reading property with dot notation -, i receive error reading property dot notation gradle.properties . why? if use version instead of build.version ok. in advance. The name of each token will be the name of the property from the properties file. For convenience, The plugin will also create a filter with the property name in dot notation to allow re-use of file templates created for Ant builds. The plugin only creates dot notation tokens for properties that start with a lower case letter.


And another one:

println property('build.version')
println "Version: ${property('build.version')}"

or

println ext['build.version']
println "Version: ${ext['build.version']}"

See Properties and Extra Properties documentation.

stevesaliman/gradle-properties-plugin: Gradle plugin to , Gradle plugin to simplify loading project properties from external environment If the ${gradleUserName} property is set, the properties plugin will load properties property name in dot notation to allow re-use of file templates created for Ant If a environment specific file is not found, the plugin will cause the build to fail  The name of each token will be the name of the property from the properties file. For convenience, The plugin will also create a filter with the property name in dot notation to allow re-use of file templates created for Ant builds. The plugin only creates dot notation tokens for properties that start with a lower case letter.


Allow the plugin DSL to expand properties as part of the version , The build fails with Read gradle.properites values in plugins block use dot properties for a lot of things, e.g. sonarqube.version , this property is to this kind of notation, or am I bound to duplicate the property named as a  When using the second forms (i.e. Groovy notation), Groovy's MissingPropertyException will be thrown instead. boolean has ( String name) Returns whether or not the extension has a property registered via the given name.


Read Gradle Goodness Notebook, gradle.properties fail reading property with dot notation. I receive an error reading a property with dot notation from gradle.properties. Why? If I use version  In Gradle, properties can be defined in the build script, in a gradle.properties file or as parameters on the command line. It’s common to declare properties on the command line for ad-hoc scenarios. For example you may want to pass in a specific property value to control runtime behavior just for this one invocation of the build.


Resource Filtering with Gradle, FAILURE: Could not determine which task to execute. Cause: Cannot set the value of read-only property 'name' on root project 'project'. So what can we In the Gradle build script we can access the properties with dotted notation: config. $ gradle showProperties:showProperties Version: 4.0 Custom property: Property value from gradle.properties BUILD SUCCESSFUL Total time: 1.676 secs Passing properties via the command line Instead of defining the property directly in the build script or external file, we can use the -P command-line option to add an extra property to a build.