Alien
Alien

Reputation: 109

Not able to concat property value in gradle

I am trying to concat the value which is there in my version.properties file but it is not concatenating to the value in my build.gradle file. Below is my code snippet.

task dist(type: Zip) {
    baseName = 'ml'
    appendix = 'cicd'

    def props = new Properties()
    file("version.properties").withInputStream { props.load(it)

    into("${baseName}-${appendix}-${version}-${props.getProperty("VERSION_BUILD")}")
}

Upvotes: 1

Views: 795

Answers (1)

Bjørn Vester
Bjørn Vester

Reputation: 7600

You can't have the same type of quotation mark inside a quoted string. Either move the code in the GString to a variable outside, escape the quotes or use single quotes inside the double quotes. I find the first approach more readable.

def versionBuild = props.getProperty("VERSION_BUILD")
into("${baseName}-${appendix}-${version}-${versionBuild}")

Upvotes: 2

Related Questions