# How to call an external gradle script once with all tasks to run from original script

**URL:** <https://discuss.gradle.org/t/how-to-call-an-external-gradle-script-once-with-all-tasks-to-run-from-original-script/9466>\
**Category:** Help/Discuss\
**Created:** [May 4, 2015, 10:10pm UTC](https://discuss.gradle.org/t/how-to-call-an-external-gradle-script-once-with-all-tasks-to-run-from-original-script/9466 "2015-05-04T22:10:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill\_phillips](https://avatars.discourse-cdn.com/v4/letter/b/7c8e57/32.png) [@bill\_phillips](https://discuss.gradle.org/u/bill_phillips)\
**Post date:** [May 4, 2015, 10:10pm UTC](https://discuss.gradle.org/t/how-to-call-an-external-gradle-script-once-with-all-tasks-to-run-from-original-script/9466/1 "2015-05-04T22:10:51Z")

</div>

I have two build scripts:  
Script A (a multi-project build with 6 sub projects)  
Script B (a multi-project build with 20+ sub projects)

The B script drives a third party compilation tool that makes assumptions about being in the root of the overall build. The result is that A & B cannot be included in a single unified multi-project build.

I’ve been asked to tie the scripts together so that a developer can execute the gradle once in the root directory and have everything build.

I figured out one way to do this at a task level:

```
task clean(type: GradleBuild) {
     buildFile = '../other/build.gradle'
     tasks = ['clean']
}

task build(type: GradleBuild) {
    buildFile = '../other/build.gradle'
    tasks = ['build']
}

task cleanEclipse(type: GradleBuild) {
    buildFile = '../other/build.gradle'
    tasks = ['cleanEclipse']
}

task eclipse(type: GradleBuild) {
    buildFile = '../other/build.gradle'
    tasks = ['eclipse']
}

```

However, with this structure, the execution takes significantly more time than running the two scripts separately. I figure this is due to the overhead of spinning up a separate external build for each task.

From the A script, I am looking for a way to call the B script just once, passing all of the command line arguments. Ideally, this would mean just one B-script execution.

I am sure this can be done, I’m just not sure how.

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [May 4, 2015, 11:32pm UTC](https://discuss.gradle.org/t/how-to-call-an-external-gradle-script-once-with-all-tasks-to-run-from-original-script/9466/2 "2015-05-04T23:32:54Z")

</div>

If I am understanding you correctly you could call the ‘B’ project with the same task arguments used to run ‘A’.

```
task buildProjectB(type: GradleBuild) {
    tasks = gradle.startParameter.taskNames
}
```
