Skip to content

jjohannes/gradle-project-setup-howto

Repository files navigation

How to set up a larger Gradle project

This repo shows one possibility to structure a Gradle project when you want:

  • Centralized and maintainable build configuration and custom build logic
  • No dependency hell through smart dependency management with dependency rules and analysis

There are four variations of this available:

The structure though, is good for any kind of project you may build with Gradle (Kotlin, Groovy, Scala, ...)

This is following the same patterns as idiomatic-gradle but is closer to a full setup that also takes the aspect of continuously changing dependencies into account.

Pick one of these similar videos to get a quick overview:

And here is an overview in a thread on Mastodon:

Project Overview

Different structuring concerns are summarized in commits if you like to explore things one-by-one:

Any kind of project

Any kind of project (except Java Module System)

Android projects

  • Android plugins
    Here, the Application plugins are changed into Android plugins and adjusted to target Android App development using the Android Gradle Plugins.
    • This repo focuses on general project structuring and dependency management with Gradle and does not go into many Android specifics. I recommend to check out https://github.com/android/nowinandroid in addition for that.

Java Module System projects

Kotlin JVM projects

Overview of your Convention Plugins

There is a help task that you can use to get a diagram of the convention plugins defined in the project:

./gradlew :plugins:analysePluginApplicationOrder

The task generates a PlantUML file that you can render, for example, with the PlantUML IntelliJ plugin.

Notes

  • If you have a question, please ask in an issue.
  • The concrete things done in all places (custom tasks, components used in dependencies, additional plugins applied, etc.) are just examples. If you, for example, need to use additional Gradle plugins you can add these in the corresponding place, keeping the suggested structure.
  • This setup uses a platform project to centralize dependency versions. An alternative approach is to use a dependency version catalog. If you prefer to use a catalog, because it is the better fit in your case, you can still follow the setup proposed here (just without the gradle/platform project).

FAQ

List of questions asked in issues so far.

More questions or points you would like to discuss? Please open an issue.

About

How to structure a growing Gradle project with smart dependency management?

Topics

Resources

License

Stars

Watchers

Forks