All Projects → jjohannes → idiomatic-gradle

jjohannes / idiomatic-gradle

Licence: other
How do I idiomatically structure a large build with Gradle 7.2+?

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to idiomatic-gradle

openjfx-docs
Getting started guide for JavaFX 11
Stars: ✭ 70 (-45.74%)
Mutual labels:  gradle, examples
Samples
JavaFX samples to run with different options and build tools
Stars: ✭ 352 (+172.87%)
Mutual labels:  gradle, examples
Jaxws Samples
Small example projects using JAX-WS technologies.
Stars: ✭ 11 (-91.47%)
Mutual labels:  gradle, examples
examples
Enjoy our curated collection of examples and solutions. Use these patterns to build your own robust and scalable applications.
Stars: ✭ 960 (+644.19%)
Mutual labels:  examples
gradle-localization-plugin
Gradle plugin for automating the download process of localization files.
Stars: ✭ 19 (-85.27%)
Mutual labels:  gradle
addon-example
Example - Home Assistant Community Add-ons
Stars: ✭ 73 (-43.41%)
Mutual labels:  examples
vuepress-plugin-live
Make your markdown code examples come alive
Stars: ✭ 37 (-71.32%)
Mutual labels:  examples
karibu10-helloworld-application
Karibu-DSL HelloWorld application in Vaadin 14
Stars: ✭ 14 (-89.15%)
Mutual labels:  gradle
spark-gradle-template
Apache Spark in your IDE with gradle
Stars: ✭ 39 (-69.77%)
Mutual labels:  gradle
db2-samples
Db2 application code, configuration samples, and other examples
Stars: ✭ 56 (-56.59%)
Mutual labels:  examples
webgl-shader-examples
Some simple examples of WebGL shaders
Stars: ✭ 83 (-35.66%)
Mutual labels:  examples
examples
Network Service Mesh examples repo
Stars: ✭ 14 (-89.15%)
Mutual labels:  examples
spring-cloud-gcp-guestbook
No description or website provided.
Stars: ✭ 55 (-57.36%)
Mutual labels:  examples
gradle-nunit-plugin
A gradle plugin for launching NUnit tests
Stars: ✭ 17 (-86.82%)
Mutual labels:  gradle
Java
All Examples for learning Java programming and algorithms
Stars: ✭ 14 (-89.15%)
Mutual labels:  examples
DexHelper
Gradle Plugin to analyze per-dex with Android assemble command.
Stars: ✭ 19 (-85.27%)
Mutual labels:  gradle
dagger2-kotlin
dagger2,querydsl kotlin 1.5.x annotation processor, gradle 7.x
Stars: ✭ 56 (-56.59%)
Mutual labels:  gradle
gradle-build-info-plugin
Gradle plugin to include build information such as Git commit ID to your JAR. It can be used to show Git commit information with Spring Boot Actuator.
Stars: ✭ 33 (-74.42%)
Mutual labels:  gradle
flytesnacks
Flyte User-Guides and Tutorials - https://flytecookbook.readthedocs.io
Stars: ✭ 39 (-69.77%)
Mutual labels:  examples
gradle-jenkins-jobdsl-plugin
A plugin for Gradle to manage Jenkins Job DSL projects.
Stars: ✭ 48 (-62.79%)
Mutual labels:  gradle

Example of how to idiomatically structure a large build with Gradle 7.2+

For a better understanding of the concepts used in this example, check out Understanding Gradle.

Example

There is now documentation and another sample on this topic in the Gradle User Manual.

This example is a software product called Idiomatic Gradle (IG).

To build the example, clone this repository and run the following for more information:

  • ./gradlew :tasks
  • ./gradlew :projects

This example consists of:

Production code

Inside the 'product' folder, there are three components/builds:

  • product/ig-server: A server providing some services
  • product/ig-api: A client API Jar that clients (e.g. Android Apps) can integrate directly
  • product/ig-common: Some common code used by both Server and API Jar

For the sake of the sample each of these folders only contain one subproject. In a real-world application, this can be structured into many, many more Gradle subprojects.

Packaging and Publishing

Both the server and the client API Jar require some special packaging to be published/distributed. Hence, this is configured in a separate component/build only responsible for aggregating build results:

  • aggregation/package-server: Package the complete server and its dependencies into one fat jar that can run without other dependencies
  • aggregation/publish-api: Package the client into one Jar that is published to a Maven repository

Testing

Each project contains unit tests using Gradle's default setup for Java projects with the src/test/java folder. Furthermore, some projects contain end2end tests testing with the real (packaged) server and the real client API Jar. For this, the packaging/publishing projects provide their results in the build for other subprojects to consume.

Idiomatic Build Logic Structure

The build contains some standard configuration for Java compilation and testing. It contains more involved configuration code to configure the packaging/publishing and the end2end test setup. There are multiple ways to do all this in Gradle today. This sample employs the following good patterns which result in a good build structure (easy to maintain and fast for Gradle to execute) as described here.

With this, the following outdated practices are avoided:

  • No direct dependencies between tasks declared (except for extending lifecycle tasks like assemble or check)
  • No direct dependencies between tasks from different subprojects are declared
  • No cross-project configuration (subproject / allprojects) is performed
  • Each build script of a subproject is simpler to read as all relationships to other projects are expressed in terms of dependencies
  • ...
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].