On 13/03/10 7:50 AM, Jeff Brown wrote:
 From within a gradle build I need to kickoff a gradle build of another
project.  The projects are not really subprojects and don't share any
directory structure.  I will know via a system property where the
second project is and I know ahead of time the name of the target that
I need to execute in the second project.  Both projects are setup to
be built with the gradle wrapper.

How can I configure "project a" to initiate a build of "project b" for
a scenario like that?


In the Gradle 0.9 release, there will be a GradleBuild task you can use to execute a build. This task is available in recent 0.9 snapshots. Some examples at http://gradle.org/latest/docs/userguide/organizing_build_logic.html#sec:external_build

In Gradle 0.8, you can use the GradleLauncher API to execute a build (this is what the GradleBuild task uses). For example:

task otherBuild << {
    // use a copy of our existing build
    def startParams = gradle.startParameter.newBuild()
    // configure the project dir and which tasks to execute
    startParams.currentDir = otherProjectDir
    startParams.taskNames = ['someTask']
    // run the build
    GradleLauncher.newInstance(startParams).run().rethrowFailure()
}

Have a look at http://gradle.org/0.8/docs/javadoc/org/gradle/GradleLauncher.html and http://gradle.org/0.8/docs/javadoc/org/gradle/StartParameter.html for more details.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to