Can I in any way alter the settings.gradle at runtime?

(Jesper Thuun-Petersen) #1

I have a gradle task which checks out a list of code modules, which in turn should work as a multiproject build. In this process, I alter the settings.gradle to include these modules. How can I make gradle realize the change, and run ‘assemble idea’ in the same gradle invocation?

(Peter Niederwieser) #2

‘settings.gradle’ is evaluated in the initialization phase. Tasks execute in the execution phase (i.e. two phases later). Hence they can’t change ‘settings.gradle’ of the same build. I’d consider using a task of type ‘GradleBuild’ instead.

(Jesper Thuun-Petersen) #3

Thanks a lot, that was what I was suspecting. I had success with the GradleBuild task type , although the daemon is giving me some problems:

Caused by: java.lang.IllegalStateException: Cache ‘E:\code.gradle\caches\1.7\scripts\build_6mb1cdeof5vnmrs8mmdqfqp709\ProjectScript\buildscript’ is already open with different state.

This exception isn’t thrown when I run my script with the --no-daemon parameter.

(Jesper Thuun-Petersen) #4

Would that exception happen to be an existing issue, or can I do something to avoid the exception (other than disabling the daemon)?

(Peter Niederwieser) #5

It might be an existing limitation. Try to configure the embedded build to run from a different base directory.