Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy string from gradle properties file behaving not as intended

Tags:

gradle

groovy

I am trying to publish a Java library to Bintray and encountered a weird behavior of strings that i get from the gradle.properties file.

Content of properties file:

testString = 'test'

My task for testing the string behavior:

task weirdString {
    println(testString)
    println('test')
    println(testString.class)
    println('test'.class)
    println(testString.equals('test'))
}

Running the task outputs:

'test'
test
class java.lang.String
class java.lang.String
false

I can't wrap my head around this. The difference between the first and the second output makes my deployment task crash. I guess this is some internal Groovy magic. Can someone enlighten me?

like image 357
Luca Fülbier Avatar asked Oct 29 '25 01:10

Luca Fülbier


1 Answers

In properties files you do not need quotes to wrap strings. Just write

testString=test
like image 198
AdamSkywalker Avatar answered Oct 31 '25 09:10

AdamSkywalker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!