Easy way / command line option to exclude a project from multi-project builds

While there’s a command line option to exclude a (dependent) task from execution ("-x/–exclude-task"), there nothing like that for the project-level in multi-project builds AFAIK.

Background: Our settings.gradle file contains the main app and examples. Usually, a developer wants to locally build both. For example, running “./gradlew lint” should run “lint” on “app” and “examples”. But sometimes, we’d like to not build the examples to speed up the build. Currently, we’re doing this by wrapping the “include ‘:examples’” directive in setting.gradle in a conditional that checks for a property, which we can set form the command line. But unfortunately this does e.g. not work with Android Studio [1]. So simply having an --exclude-project command line option would be nice.

[1] https://code.google.com/p/android/issues/detail?id=80193

You could just run ‘gradlew lint’ from the ‘app’ directory, or run ‘gradlew :app:lint’ from the top.

True, for my simplified example that would work. But the app is in fact split into multiple library projects. What you suggest would only run lint on the app code, but what I’d like to do is to run lint on the app and all (dependent) library projects, but not the example code.

You could model that as a task that depends on all non-example lint tasks.

Sure. But my point is that I believe this is such a common requirement that there should be no need to model a task, but that Gradle should provide some built-in means to accomplish that.

I see some pros and cons for this feature. Anyway, I’ve filed GRADLE-3199 for this. Thanks for the suggestion.

Thanks for considering!