Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a Gradle task before subprojects are evaluated

I've set up a Gradle task to auto generate one of the subprojects of my Gradle build on which another depends (reason for doing this: long story involving Apache Cordova!). So the root build.gradle contains this autogenerate task that creates a "CordovaLib" sub project. The build.gradle in the other sub project (that isn't autogenerated) depends on CordovaLib:

dependencies {
    compile project(':CordovaLib')
}

Is there a way to execute the autogenerate task before the non-generated subproject's build.gradle is evaluated (specifically the above line)? I'm using Gradle 1.11 on JDK 1.7 and as it currently stands I can't even run gradle tasks without it failing due to the missing project.

like image 631
Keir Avatar asked Nov 02 '22 02:11

Keir


1 Answers

It isn't possible to execute a task before build files have been evaluated, at least not without complications such as one build executing another build using a GradleBuild task. You are likely better off checking the generated project in to source control, or finding a solution that doesn't involve generating build scripts.

like image 153
Peter Niederwieser Avatar answered Nov 09 '22 09:11

Peter Niederwieser