I have three Gradle builds: common, core and web. core and web both depend on common but web does not depend on core. core is a multi-project build. Here’s the file structure:
root common build.gradle core a/b/c build.gradle d/e/f build.gradle g/h/i build.gradle build.gradle shared.gradle settings.gradle web build.gradle
common can build by itself. web is set up so that it depends on common. When I run gradle build on core, it builds everything specified in the settings.gradle file correctly.
What my team would like to do is enable building from the root folder as well as the core folder. Currently they only have to type gradle in any of the top-level projects to build them and we’d like to keep it that way.
The problem comes in when I put a settings.gradle file in the root directory. Since the projects are now nested one level deeper, I need to include core/a/b/c instead of a/b/c. Some of the projects within core reference other projects and these references result in an error when building from the root directory (because core/a/b/c is a known project but a/b/c is not).
I tried fixing all of the references, but this prevents me from going to the core directory and building only the projects contained in core.
With Maven, this feature (building part of a project instead of the whole thing by changing to a subdirectory) seems to work in a very intuitive fashion. How can I set my Gradle project up to do the same thing?
What I want is to be able to run something like gradle clean build and have it run those tasks on each of the projects, but to run those tasks only on the projects contained within my current directory.