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?
‘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.
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.
Would that exception happen to be an existing issue, or can I do something to avoid the exception (other than disabling the daemon)?
It might be an existing limitation. Try to configure the embedded build to run from a different base directory.