# Running tasks on nested subprojects

**URL:** <https://discuss.gradle.org/t/running-tasks-on-nested-subprojects/19980>\
**Category:** Help/Discuss\
**Created:** [October 13, 2016, 2:36pm UTC](https://discuss.gradle.org/t/running-tasks-on-nested-subprojects/19980 "2016-10-13T14:36:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwa](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jwa](https://discuss.gradle.org/u/jwa)\
**Post date:** [October 13, 2016, 2:36pm UTC](https://discuss.gradle.org/t/running-tasks-on-nested-subprojects/19980/1 "2016-10-13T14:36:12Z")

</div>

Let’s assume that I have the following project structure:

```
:API:Payment:Card
:API:Payment:Cash
:API:BackOffice:StockKeeping
:Client:PointOfSale
:Server:StockLedger

```

How can I chose to run a task on all subprojects that are nested underneath a specific subproject?

For example, if I want to run `compileJava` on all the subprojects under `:API`, how do I achieve that?

I have tried `gradlew :API:compileJava`, but that only attempts to run the `compileJava` task on `:API`, and none of it’s nested subprojects.

It’s worth noting that the `:API` project does not apply the java plugin, given it does not contain any Java code. Instead, it contains the nested subprojects, which themselves apply the java plugin and contain code.

---

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [October 13, 2016, 3:30pm UTC](https://discuss.gradle.org/t/running-tasks-on-nested-subprojects/19980/2 "2016-10-13T15:30:44Z")

</div>

You can use `gradle -p API compileJava`. This will behave just like calling Gradle in that subdirectory.

We have planned a better solution for this, which will probably look like this: `gradle API::compileJava` ( note the double colon). I don’t yet have a target version for that feature though.
