Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boolean properties in gradle.properties file is read as string

I am new to gradle. I have a boolean property in gradle.properties file. When I tried to access it, the property is set as string. The string property always seemed to be evaluated as true when the string is not null and not empty.

My gradle.properties looks like this

enableGradleApp=false 

and my settings.gradle looks like

if (enableGradleApp) { println 'Enabled core' } 

The message 'Enabled Core' is always gets printed.

Need some help please

like image 293
Captain Buck Avatar asked Jan 29 '16 06:01

Captain Buck


People also ask

How do you set a Boolean value in properties file?

When the Properties of your file are loaded you can use the Boolean -Class to get the Properties: Boolean. getBoolean("your. property");

Where can I find gradle properties file?

properties in the project folder or in the C:\Users\Username. gradle.


1 Answers

I had the same problem, but I just converted it to boolean like this:

if (enableGradleApp.toBoolean()) {   .... } 
like image 158
Sten Roger Sandvik Avatar answered Sep 20 '22 19:09

Sten Roger Sandvik