with dynamic properties

(suman jakkula) #1

I want to define a gradle property such as below in newWorkdDir=${buildDir}/newWork dbUrl=“jdbc:h2:mem:${}-db;INIT=SET SCHEMA APPLICATION_USER”

In few test resource files, I am referring to this newWorkdDir for replacement. actualWorkdDir=${newWorkdDir}

processTestResources() task is not able to replace to populate actualWorkdDir with ${buildDir}/newWork expansion. Instead I see it as “${buildDir}/newWork”. How do I make it expand the value when processing resources? Same is the scenario for dbUrl. In resource files that refer to dbUrl, I dont get the expanded value.

(suman jakkula) #2

figured out… below code resolved my query. expand( was the key

allprojects {
    processTestResources {
        include '**/*.properties'
        include '**/*.xml'
 tempAntProject = new { k, v ->
            v instanceof String && tempAntProject.setProperty(k,v)
        filter(ExpandProperties, project : tempAntProject )

(René Groeschke) #3

thanks for sharing your solution with us