How do I set properties from a File for Test task?

(Pablo Munoz) #1

this doesn’t work for example:

test {

Properties props = new Properties()

props.load(new FileInputStream("/path/"))

systemProperty ‘java.library.path’, props.getProperty(‘’) }

doFirst and beforeTest don’t help either

(Peter Niederwieser) #2

I can’t spot a problem with this code. Are you sure that the problem isn’t somewhere else?

(Pablo Munoz) #3

You were right Peter. The problem is that the property file is generated by another task, thus not available at configuration phase. How can I make the systempProperty lazy binding?

(Pablo Munoz) #4

nevermind, doFirst works!

(Peter Niederwieser) #5

One solution is to make the ‘test’ task depend on that other task, and configure the system properties in ‘test.doFirst { … }’. Or maybe you can refactor the other task so that both tasks consume the ‘java.library.path’ value from the same source of information (and you don’t have to parse the properties file to get at the value).

(Peter Niederwieser) #6

The main drawback of configuring stuff in ‘doFirst’ is that this information isn’t considered for the task’s up-to-date check (because it comes to late). However, this is probably tolerable in this case.