{"id":19553088,"url":"https://github.com/jjohannes/idiomatic-gradle","last_synced_at":"2025-04-05T00:10:19.468Z","repository":{"id":39164425,"uuid":"273016199","full_name":"jjohannes/idiomatic-gradle","owner":"jjohannes","description":"How do I idiomatically structure a large build with Gradle 7.2+?","archived":false,"fork":false,"pushed_at":"2024-06-24T10:55:15.000Z","size":315,"stargazers_count":505,"open_issues_count":5,"forks_count":23,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-03-28T23:08:54.263Z","etag":null,"topics":["android","examples","gradle","java"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/playlist?list=PLWQK2ZdV4Yl2k2OmC_gsjDpdIBTN0qqkE","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jjohannes.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-17T15:49:54.000Z","updated_at":"2025-03-27T14:27:56.000Z","dependencies_parsed_at":"2024-11-11T04:23:27.140Z","dependency_job_id":"2fccf1a2-2860-4473-ac6d-b9ad5e969635","html_url":"https://github.com/jjohannes/idiomatic-gradle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjohannes%2Fidiomatic-gradle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjohannes%2Fidiomatic-gradle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjohannes%2Fidiomatic-gradle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jjohannes%2Fidiomatic-gradle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jjohannes","download_url":"https://codeload.github.com/jjohannes/idiomatic-gradle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266565,"owners_count":20910836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","examples","gradle","java"],"created_at":"2024-11-11T04:21:28.985Z","updated_at":"2025-04-05T00:10:19.444Z","avatar_url":"https://github.com/jjohannes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example of how to idiomatically structure a large build with Gradle 7.2+\n\n\u003e [!IMPORTANT]\n\u003e This project shows how to use Gradle in a structured way not only for simple, but also rather complex project setups.\n\u003e In this context, it is rather \"academic\" and contains quite some \"Gradle boilerplate\".\n\u003e If you want to understand Gradle on a deeper level, it is a great resource.\n\u003e And if you are looking for more explanation on the different features used here, you can finde that in my\n\u003e 👉 [**Understanding Gradle**](https://github.com/jjohannes/understanding-gradle#readme) video series.\n\u003e\n\u003e If you are looking for a (more or less) standard setup for a project, I would recommend looking at my other repository\n\u003e 👉 [**Gradle Project Setup HowTo**](https://github.com/jjohannes/gradle-project-setup-howto) first or instead.\n\nThere is also\n[documentation](https://docs.gradle.org/release-nightly/userguide/structuring_software_products.html)\nand another\n[sample](https://docs.gradle.org/release-nightly/samples/sample_structuring_software_projects.html)\non this topic in the Gradle User Manual.\n\n## Example\n\nThis example is a software product called _Idiomatic Gradle (IG)_.\n\nTo build the example, clone this repository and run the following for more information:\n- `./gradlew :tasks`\n- `./gradlew :projects`\n\nThis example consists of:\n\n### Production code\n\nInside the 'product' folder, there are three components/builds:\n\n- `product/ig-server`: A server providing some services\n- `product/ig-api`: A client API Jar that clients (e.g. Android Apps) can integrate directly\n- `product/ig-common`: Some common code used by both Server and API Jar\n\nFor the sake of the sample each of these folders only contain one subproject.\nIn a real-world application, this can be structured into many, many more Gradle subprojects.\n\n### Packaging and Publishing\n\nBoth the server and the client API Jar require some special packaging to be published/distributed.\nHence, this is configured in a separate component/build only responsible for aggregating build results:\n- `aggregation/package-server`: Package the complete server and its dependencies into one fat jar that can run without other dependencies\n- `aggregation/publish-api`: Package the client into one Jar that is published to a Maven repository\n\n### Testing\n\nEach project contains unit tests using Gradle's default setup for Java projects with the `src/test/java` folder.\nFurthermore, some projects contain end2end tests testing with the real (packaged) server and the real client API Jar.\nFor this, the packaging/publishing projects _provide_ their results in the build for other subprojects to consume.\n\n## Idiomatic Build Logic Structure\n\nThe build contains some standard configuration for Java compilation and testing.\nIt contains more involved configuration code to configure the packaging/publishing and the end2end test setup.\nThere are multiple ways to do all this in Gradle today.\nThis 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](https://docs.gradle.org/release-nightly/userguide/structuring_software_products.html).\n\nWith this, the following outdated practices are avoided:\n- No direct dependencies between tasks declared (except for extending lifecycle tasks like `assemble` or `check`)\n- No direct dependencies between tasks from different subprojects are declared\n- No cross-project configuration (_subproject_ / _allprojects_) is performed\n- Each build script of a subproject is simpler to read as all relationships to other projects are expressed in terms of dependencies\n- ...\n\n## Alternative structuring options (on branches)\n\n- Alternative setups to use or not use Gradle's [Version Catalog](https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog) concept (see [#4](https://github.com/jjohannes/idiomatic-gradle/issues/4)).\n    - [Do not use the Catalog](https://github.com/jjohannes/idiomatic-gradle/commit/no_version_catalog) - Removes the `libs.versions.toml` catalog and instead uses GA coordinates directly (versions are managed in platform project)\n    - [Use only the Catalog (remove Platform)](https://github.com/jjohannes/idiomatic-gradle/commit/version_catalog_without_platform) - Remove the `gradle/platform` project and put the versions directly into the catalog instead.\n\n## Discussions and alternative structuring options\n\n- [Using or not using a Version Catalog](https://github.com/jjohannes/idiomatic-gradle/issues/4)\n- [How to use an external plugin in a local plugin and where to put its version](https://github.com/jjohannes/idiomatic-gradle/issues/14)\n- [Name of 'Settings Plugin' project](https://github.com/jjohannes/idiomatic-gradle/issues/8)\n- [Using JVM packages for precompiled script plugins](https://github.com/jjohannes/idiomatic-gradle/issues/9)\n- [Where to put the Gradle Wrapper](https://github.com/jjohannes/idiomatic-gradle/issues/12)\n\nMore questions or points you would like to discuss? Please [open an issue](https://github.com/jjohannes/idiomatic-gradle/issues/new).\n\n## FAQ\n\n- [Android Studio: 'gradle/plugins' project clean uses different Gradle version](https://github.com/jjohannes/idiomatic-gradle/issues/5)\n\nMore questions or points you would like to discuss? Please [open an issue](https://github.com/jjohannes/idiomatic-gradle/issues/new).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjohannes%2Fidiomatic-gradle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjjohannes%2Fidiomatic-gradle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjjohannes%2Fidiomatic-gradle/lists"}