Jmini
Jmini

Reputation: 9507

Add a random value for a key in "-runproperties" in a "*.bndrun" file

When I am running tests using bnd (from the Bndtools project) through gradle, I would like to set a random value in test.bndrun:

-runproperties: \
    osgi.instance.area=random_value

Where random_value would be something random (like "area_" + <currentTimeMillis>).

Is there a possibility to express that without having a script or a gradle task to modify the test.bndrun file?

Upvotes: 0

Views: 24

Answers (1)

Jmini
Jmini

Reputation: 9507

I found a solution to this:

In the test.bndrun I have:

-runproperties: \
    osgi.instance.area=area_${randomTimestamp}

And in the Gradle Task, I prepare the value randomTimestamp:

def testOSGi = tasks.register('testOSGi', aQute.bnd.gradle.TestOSGi) {
    dependsOn resolve
    bundles = files(sourceSets.osgiTest.runtimeClasspath, configurations.archives.artifacts.files)
    bndrun = file('test.bndrun')
    properties = ['randomTimestamp': System.currentTimeMillis()]
}

Upvotes: 0

Related Questions