Is it possible to skip project for global assemble or build task?

So not sure if this is possible or not but, lets say I have 3 projects, A, B, and C, in a multi-project build. Each project is a java project and C’s sources depend on B’s, and B’s depends on A. So the structure looks roughly like:

root
|-- build.gradle
|-- settings.gradle
|-- A
|
  '- build.gradle
|-- B
|
  '- build.gradle
|-- C
|
  '- build.gradle
<code>
  each <code>build.gradle<code> applies <code>plugin: 'java'

Is it possible to make

./gradlew assemble

in the root directory build only projects A and B, but not build C. C could then be build manually with either

./gradlew C:assemble

or

cd C; ../gradlew assemble

?

Thanks!

You can do this one of two ways. Explicitly specify the projects you do want to assemble.

./gradlew A:assemble B:assemble

Or you can exclude a particular task.

./gradlew -x C:assemble assemble

Thank you for the response. Is there a way to make it the default? The use case is I’m integrating gradle to replace a mess of ant and make at my company. C:assemble’s analogue in make/ant is simply not invoked in the current build system because it is not used for 99% of use cases. I’d like to make it so the casual developer may run ./gradlew assemble and it’ll be “optimized” for them.

Same kind of idea, there are a couple of ways you define that in your build script.

Define a custom task that depends on just the projects you want to run.

task devAssemble(dependsOn: [‘A:assemble’, ‘:b:assemble’]) { }

You could additionally set that task (or additional tasks) as the project default task, allowing a developer do simply run ‘gradle’.

defaultTasks devAssemble

Also, you could fine some condition so project C is only ever run under certain circumstances (certain property defined, environment variable, etc).

// project C build.gradle

assemble {

onlyIf {

project.hasProperty(‘runAll’)

}

}

Excellent, this is great information. I’ll poke around and figure out something that works for me. Thank you!