Gradle invoking Gradle


(Bob Bell) #1

So I can get into the reasons why if need be, but for now perhaps it suffices to say that I am considering a model whereby one Gradle build would “bootstrap” another Gradle build. That is, the first invocation of Gradle would be somewhat minimal, and it would primarily identify the necessary version and then pull down code for another Gradle build, which would be more substantial. The build would essentially have a “hand-off” from the first “bootstrap” build to the secondary “main” build.

Is there any precedence for this sort of thing? Are there any suggestions for having one Gradle build invoke another build? The Gradle code for the second build wouldn’t initially be present, and the first build will have moved to the Execution phase of the Gradle lifecycle already once the code for the “primary” build is available, so I don’t think I can truly make the two builds one. Therefore, right now I’m thinking I couldn’t really do much beyond Execing Gradle (or gradlew) again for the second build.

However, if there’s a better suggestion out there, I’m certainly all ears…


(Stefan Oehme) #2

Have you looked at the GradleBuild task?


(Bob Bell) #3

Nope. I hadn’t run into that yet. In fact, I had to do a quick search to see if it’s mentioned anywhere in the non-generated documentation, and only found one place, where it is discouraged. Still, this seems like the “corner case” where it could make sense. Thanks!


(Stefan Oehme) #4

We’ve often seen it misused which is why we discourage it :slight_smile: Without knowing more about your use case I would say it probably makes sense for you.


(Bob Bell) #5

Yes, that makes sense. I’m aware of multi-project builds, and composite builds, and I’m actually using both of those. This case is a bit more unique because some of the Gradle code wouldn’t exist until the some Gradle tasks had executed, so I think it makes sense here. I’ll continue to think through the design, and will definitely include GradleBuild.