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

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

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

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?

nevermind, doFirst works!

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).

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.