This is a shared gradle build setup for java projects of any size, whether you're working on a single library, 100+ separate git repositories, or a few multi-module projects sitting side by side.
Everything runs in java through the gradle wrapper. Building, testing, checking module dependencies and signing releases should work right away with just the JDK installed.
Supports focused views, parallel clones, and one atomic merge:
Here upstream modules swap for pre-built jars and the same test run comes back through quickcheck
Here we clone the worktree at an old tag, fix and test on JDK 21, tag and publish from the detached view, cherry-pick only the fix, then clean up the clone:
All while the work on the main reactor goes on unaffected. You can work on many parallel views at the same time.
It should allow you to use gradle WELL and painlessly even if you don't know anything about it and doesn't care to learn (and re-learn every time you switch projects)
I have always hated on gradle because it can be HARD to get it doing what you want and every new project is a new "adventure" filled of script hell no one understands. Maven and declarative build configs are WAY easier - learn the recipe and repeat it everywhere. But maven can way too slow - especially if you have many large subprojects or modules. Reusing your configs also means some degree of copy-pasting which I find annoying to say the least.
I hope to have solved many of the issues of BOTH maven and gradle here and added a few extra batteries too.
When you have several java libraries or modules that depend on each other, you usually end up stuck between two not-so-great choices: cram everything into one giant git repository, or publish a new version of library A every time you want to test a change in library B.
This parent lets you skip both (hopefully). The idea here is that you can keep each project in its own folder, with its own git repository (if you want), and build all of them together in one gradle workspace:
-
Build separate projects together
- Put each project folder next to
parent/and gradle picks it up automatically, so one project can depend on another withproject(":core") - gradle/libs.versions.toml: keeps all your library, plugin, and Java versions in one shared file
- gradle/reactor.properties: keeps project info, test runner choice, and build options in one place
- Put each project folder next to
-
Work on just a small slice of a big workspace
- createView: when a workspace grows to dozens of projects, you can generate a smaller workspace that only loads one project and the projects it uses
- viewClone: creates an isolated git copy of those projects on a temporary branch so you can edit and test safely, keep every project on the same branch, and merge everything back cleanly without leaving half of your repos merged and the other half stuck
- viewAddModule and viewRetireModule: split out a brand-new module or retire an obsolete one inside a worktree clone, then promote or archive it atomically during viewMerge
See Focused mini-reactor views and isolated git worktree clones.
-
Tag releases, rebuild past versions, and target older java versions
- isOss: mark open-source libraries with
ext["isOss"] = truewhile keeping private projects separate - prepareRelease: run your configured pre-release checks, bump the semantic version, and create the release git tag without guessing missing settings
- releaseManifest and viewFromTag: save the exact git tags used for a release so you can recreate and test that exact release later on
- -PtargetJdk: compile and run tests for an older java version like java 21 with a single flag
- isOss: mark open-source libraries with
-
Safe publishing with built-in signing
- publish: makes sure your git folder has no uncommitted edits, runs any configured
reactor.publish.taskschecks, and sits on the right release tag before uploading anything. For maven central, it signs your files in memory with PGP. For private maven repositories (nexus, artifactory, or self-hosted servers), it uploads older-java builds under separate names liketext-jdk21. - ReactorSecrets: reads usernames, tokens, and signing keys from a file stored outside git
- templates/github/publish.yml and templates/github/publish-backport.yml: ready-to-use github actions workflows for tagged releases and backports
- publish: makes sure your git folder has no uncommitted edits, runs any configured
-
Packaging, opt-in code checks, fast profiles, and checked documentation
- shadeEmbed / shadeBundle / postShadeJar: bundle third-party libraries cleanly inside java modules or package standalone runnable jars. See Shading and non-modular dependencies
- SpotBugs & PMD CPD, opt-in JaCoCo: keep normal
:testloops fast (jacoco instrumentation only activates when ajacoco*task is requested, matching spotbugs and CPD) and inspect module dependencies in a browser. See Quality, static analysis, dependencies, and coupling audits - gradle/profiles.properties and reactor.deps.binary: run shorthand profiles with guardrails and timeouts (
quickcheck,deployall), override any setting via-P/-D, and swap unchanged upstream modules for pre-built jars during highly iterative work that doesn't need most of the default "perfect build with javadocs and coverage and whatever". See Fast builds, named profiles, and binary dependencies
-
Custom stuff I ported from old java code into gradle tasks
- couplingUi: to inspect module dependencies in a browser - to help clear silly and unused dependencies, and to help keep
module-info.javafiles tight. See Quality, static analysis, dependencies, and coupling audits - render-docs: a hopefully decent markdown template to help write guides like this one. If checks every markdown link, heading, and code snippet when building documentation. Since I'm dumb and I kept editing the rendered markdown instead of the template,
render-docs --checkensures no drift and rescues direct edits to the rendered file back into the templates. See Writing live documentation with render-docs
- couplingUi: to inspect module dependencies in a browser - to help clear silly and unused dependencies, and to help keep
There are really just three moving parts:
parent/: holds the gradle wrapper, shared build plugins, library versions, and settings. You openparent/in your IDE or run./gradlewfrom here- Your project folders like
../core/,../app/, and../reports/: sit right next toparent/as plain folders or separate git repos, and talk to each other withproject(":core") - Views and clones: smaller temporary gradle workspaces generated from
parent/when you only want to load a few projects, try something out on a git branch of every project in the view clone, or rebuild an old release tag
That's all you need to know for now, so let's get started.
This README covers setting up a workspace, configuring parent, creating two modules, and using it with a monorepo or an existing multi-project build. After going through it, check out the dedicated guides:
- Fast builds, named profiles, and binary dependencies - keep
:testfast with opt-in coverage, override any property via-P/-D, run named profiles (quickcheck,deployall) with timeouts and guardrails, and swap unchanged upstream modules for pre-built jars - Focused mini-reactor views and isolated git worktree clones - open a smaller subset of a large workspace, edit across several git repositories on a temporary branch, and merge your changes back safely
- Versioning, releases, backports, and publishing - set up open-source and private modules, save reproducible release lists, build for older java versions, sign and publish packages, and keep private tests separate
- Shading and non-modular dependencies - bundle third-party libraries inside Java modules and package standalone runnable jar files
- Quality, static analysis, dependencies, and coupling audits - inspect dependencies, run spotbugs, PMD CPD, and jacoco coverage, view module dependencies in a browser, and run tests for
parentitself - Writing live documentation with render-docs - write markdown templates whose file links, heading links, code snippets, and images stay verified on every build
| File | Required? | What to change |
|---|---|---|
| gradle/reactor.properties | Yes | Set your reactor.name, reactor.group, reactor.base.package, reactor.target.jdk, reactor.test.framework (testng, junit, or none), vendor/developer/SCM metadata, and release tag format (reactor.release.tag.format). Or start by copying a profile from templates/reactor.properties.*. |
| gradle/libs.versions.toml | Yes | Set the build JDK (java) and add the third-party libraries, bundles, and plugins your projects use |
gradle/reactor.local.properties |
Optional (gitignored) | Machine-local overrides that should not be committed: reactor.views.root, reactor.secrets.file, reactor.extensions.dir, or a default reactor.profile. Both can also live outside the repository: a reactor.local.properties in any reactor.extensions.dir folder layers over this file, next to an optional profiles.local.properties (folders load in the order listed and conflicting values fail the build) |
| gradle/profiles.properties | Optional | Custom build profiles you can name to execute only the tasks you want (so you can run ./gradlew :<someproject>:runOnlyThisTestOrDieAfter_5_Seconds) |
| gradle/release.versions.toml | Optional | Define how you want your version numbers to look |
| gradle.properties | Optional | Adjust daemon memory (org.gradle.jvmargs) or parallel/cache flags. |
Drop each project folder next to parent/ (or under reactor.modules.dir).
my-workspace/
parent/ # a clone of this repo
my-module/
settings.gradle.kts # required: rootProject.name = "my-module"
build.gradle.kts # required: applies org.jbax.internal-conventions
src/main/java/ # your code
Inside ../my-module/settings.gradle.kts you just need the project name - this is always a one-liner (I could not figure out how to make you NOT need this file, so here it is)
rootProject.name = "my-module"And in ../my-module/build.gradle.kts you define your dependencies:
plugins { id("org.jbax.internal-conventions") } // the only thing that is required if there are no dependencies.
ext["isOss"] = true // if you want to open-source your code, keep this line. Set to false/delete for commercial/private stuff.
dependencies {
api(project(":core")) // depends on another module managed by the parent
implementation(libs.slf4j.api) // comes from parent/gradle/libs.versions.toml - where ALL libraries and their versions are defined.
}If your modules live in one git repository, or in an existing multi-project gradle build that already has its own settings.gradle.kts, see Using with a monorepo or multi-project builds.
Run ./gradlew checkReactorHealth from parent/ anytime to verify every sibling module is wired cleanly.
Starting a new multi-repo java workspace from zero takes four short steps.
Put parent/ in a workspace folder next to the Java projects you want to build together:
my-workspace/
parent/ # shared build plugins, versions, wrapper
core/ # project 1 (plain folder or its own git repo)
app/ # project 2 that uses :core
reports/ # optional: an existing multi-project gradle build
Create the folder and clone parent into it:
mkdir my-workspace
cd my-workspace
git clone <url-to-this-repo> parent
cd parentIf you'd rather name the folder something else, like build-parent/, just set reactor.build.dir=build-parent in gradle/reactor.properties.
parent/templates/ includes ready-to-copy starter files so you don't have to write gradle/reactor.properties from a blank page:
- templates/reactor.properties.common: shared defaults (package prefix, maven group, JDK, versioning, release settings, test framework)
- templates/reactor.properties.public: overrides for a public open-source repo
- templates/reactor.properties.private: overrides for a private multi-repo workspace
Copy the shared defaults plus either the private or public profile into parent/gradle/:
# For a private multi-repo workspace:
cp templates/reactor.properties.common gradle/reactor.common.properties
cp templates/reactor.properties.private gradle/reactor.properties
# Or for a single public open-source repository:
# cp templates/reactor.properties.common gradle/reactor.common.properties
# cp templates/reactor.properties.public gradle/reactor.propertiesGradle loads gradle/reactor.common.properties first and then applies gradle/reactor.properties on top. Now edit those files with your own name, maven group, base Java package, target JDK, test framework, and release settings:
# gradle/reactor.properties
reactor.name=acme-reactor
# gradle/reactor.common.properties
reactor.group=com.acme
reactor.base.package=com.acme
reactor.target.jdk=27
# testng -> adds TestNG and runs TestNG suites
# junit -> adds JUnit 5 and runs JUnit Platform tests
# none -> leaves test libraries and runners up to each module
reactor.test.framework=junit
# Release tagging and pre-release task checks used by prepareRelease
reactor.release.tag.format=v{version}
reactor.release.prepare.tasks=render-docs,test,javadoc
reactor.release.prepare.tasks.root=render-docsEvery option has comments and examples right inside gradle/reactor.properties. Put machine-local settings like your personal reactor.views.root folder or reactor.secrets.file path in gradle/reactor.local.properties so git ignores them, and put a reactor.local.properties (plus an optional profiles.local.properties) in a reactor.extensions.dir folder when you want them to live outside the repository entirely.
The main JDK version, currently java 27 under java, and every third-party library or plugin version live in gradle/libs.versions.toml. Individual modules just reference libs.<alias> from that catalog so you don't have version numbers scattered everywhere. Default version settings for internal modules live in gradle/release.versions.toml.
Instead of copying boilerplate folders by hand, run initializeModule from parent/ to create an open-source library called core and a private app called app:
./gradlew initializeModule --mode=OSS --module=core
./gradlew initializeModule --mode=INTERNAL --module=appGradle prints where both projects were created:
initialized OSS module core at /path/to/my-workspace/core
initialized INTERNAL module app at /path/to/my-workspace/app
Here's what gets generated inside ../core/:
../core/
.gitignore
build.gradle.kts
settings.gradle.kts
src/
main/
java/
module-info.java
com/acme/core/.gitkeep
resources/.gitkeep
test/
java/
com/acme/core/.gitkeep
A few things to note here:
../core/settings.gradle.ktsonly hasrootProject.name = "core", which letsparentlink it directly as a subproject../core/build.gradle.ktsappliesorg.jbax.internal-conventionsand setsext["isOss"] = truebecause we passed--mode=OSS.../app/build.gradle.ktsleaves that out, soappstays private- Since we set
reactor.test.framework=junitin Step 2, JUnit 5 is already wired up. If you picktestng,initializeModulealso generatessrc/test/resources/testng.xmlpointing tocom.acme.core.* - Each module folder can be initialized as its own git repository (
git -C ../core init) whenever you want independent commit history
If you want to create a module in a different folder instead of next to parent/, pass --target=/path/to/folder.
Let's add a simple class in ../core/src/main/java/com/acme/core/Greeter.java:
package com.acme.core;
public class Greeter {
public static String hello(String name) {
return "Hello, " + name + "!";
}
}Export its package in ../core/src/main/java/module-info.java:
open module com.acme.core {
exports com.acme.core;
}Now tell app to depend on core in ../app/build.gradle.kts:
plugins { id("org.jbax.internal-conventions") }
dependencies {
api(project(":core"))
}And declare the module requirement in ../app/src/main/java/module-info.java:
open module com.acme.app {
requires com.acme.core;
}From parent/, verify that gradle discovered both modules cleanly, check workspace health, and run your tests:
./gradlew projects
./gradlew checkReactorHealth
./gradlew testYou should see :core and :app linked up and passing the health check:
Reactor: linking core
Reactor: linking app
...
--- Reactor Health Check ---
[OK] [app]: Reactor module settings OK.
[OK] [core]: Reactor module settings OK.
To work in an IDE like intellij, just open parent/ as a gradle project and all your sibling projects will load together with the same Java version and library catalog.
If you're coming from maven, you're used to two familiar files: a parent pom that holds shared compiler settings, plugin versions, and <dependencyManagement>, and an aggregator pom.xml with <modules> that builds all your libraries together.
The catch with maven is that a multi-module <modules> reactor normally pushes you into a single giant git repository, or forces you to run mvn install on library A every time you want to test a change in library B. parent/ gives you the same shared build config and live multi-module build while letting every module stay in its own independent git repository with its own small settings.gradle.kts and build.gradle.kts.
| If you use this in maven | Use this in parent |
|---|---|
<parent> pom.xml with shared plugins and compiler config |
plugins { id("org.jbax.internal-conventions") } plus gradle/reactor.properties |
Aggregator pom.xml with <modules> |
Drop project folders next to parent/; gradle discovers them automatically and links them via project(":core") |
<dependencyManagement> / BOM |
gradle/libs.versions.toml shared version catalog (libs.<alias>) |
Maven profiles (<profiles> / -Pprofile) |
Layered gradle/reactor.common.properties, gradle/reactor.properties, gradle/reactor.local.properties plus any reactor.extensions.dir folder, and -P<key>=<value> overrides |
maven-enforcer-plugin |
Built-in --release target JDK checks, checkReactorHealth, auditBuildSystem, and clean-tree/tag publish checks |
maven-shade-plugin |
shadeEmbed, shadeBundle, and postShadeJar in shading-conventions.gradle.kts |
mvn install |
./gradlew publishToMavenLocal (writes standard jars and pom files into ~/.m2/repository) |
mvn deploy |
./gradlew publish (with clean-tree check, tag check, and in-memory PGP signing) |
mvn release:prepare |
./gradlew prepareRelease (--patch, --minor, --major, --release-version, --release-dry-run, --push) |
mvn -pl text -am test |
./gradlew -Preactor.view=text test for one command, or createView / viewClone for a focused IDE workspace |
You don't need a big-bang rewrite to move off maven:
- Keep the exact same maven coordinates by setting
reactor.groupin gradle/reactor.properties to your existing maven<groupId>. Each module's folder name becomes its<artifactId>(or<artifactId>-jdk21when building a Java 21 backport with-PtargetJdk=21), and its version comes from your git tag or version pattern. - Convert one module at a time by adding a minimal
settings.gradle.kts(rootProject.name = "core") andbuild.gradle.kts(plugins { id("org.jbax.internal-conventions") }) next to your existingsrc/main/javaandsrc/test/javafolders - gradle uses the exact samesrc/mainandsrc/testdirectory layout as maven. - Publish standard maven poms automatically. Every module gets gradle's
maven-publishplugin wired up by publishing-conventions.gradle.kts, complete with<name>,<description>,<licenses>,<developers>,<scm>, and resolved dependencies. Inspect the generated pom file anytime with:./gradlew :core:generatePomFileForMavenPublication
- Stay compatible with maven consumers by running
./gradlew :core:publishToMavenLocalso your remaining maven projects pick upcoreright from~/.m2/repository. When you're ready to deploy, pointreactor.publish.central.urlat maven central orreactor.publish.backport.urlat your private maven repository. Downstream maven builds depend on your publishedgroupId:artifactId:versionlike any normal maven library and never need gradle installed.
One line in a module's build.gradle.kts decides whether it's open-source or private:
- Open-source module: add
ext["isOss"] = true. It gets numbered versions like1.0.14or a git tag version like1.2.0, can be part of public releases via releaseManifest, and can be exported cleanly without tests or git history via publicExport - Private / internal module: leave
ext["isOss"]unset orfalse. It gets a date-based version like2026.11.25wheninternal-release = "AUTO"in gradle/release.versions.toml, and gradle won't let it slip into a public open-source release by mistake
You can flip a private module to open-source whenever you're ready by adding ext["isOss"] = true. See Versioning, releases, backports, and publishing for the full release and backport flow.
Pick the setup that matches how your modules are stored.
When every module lives in one git repository, you do not need include(...) or composite builds. Put the parent files at the repository root, place the modules under modules/, and set reactor.modules.dir=modules in gradle/reactor.properties:
my-monorepo/ # one git repository
settings.gradle.kts # parent files at the root
build.gradle.kts
build-logic/
gradle/ # reactor.properties sets reactor.modules.dir=modules
modules/
core/ # settings.gradle.kts + build.gradle.kts + src/
app/ # build.gradle.kts declares project(":core")
Every folder under modules/ is discovered automatically. ./gradlew projects lists :core and :app, -Preactor.view=app slices the reactor the same way as anywhere else, and initializeModule scaffolds new modules straight into modules/ because its default target is <reactor.modules.dir>/<module>.
The git tasks that assume one repository per module keep that assumption. Release manifests and worktree clones read git history from individual module folders, so a single-repository monorepo uses normal git branches and tags for those.
With reactor.nested.builds=true, which is the default, a sibling folder whose settings.gradle.kts calls include(...) or includeBuild(...) is attached as a gradle composite build. Gradle attaches that folder unchanged, so it still builds on its own:
my-workspace/
parent/
core/ # flat module, discovered the usual way
reports/
settings.gradle.kts # include(":reports-api", ":reports-cli")
reports-api/
reports-cli/
./gradlew projects from parent/ prints:
Reactor: linking nested build reports
Reactor: linking core
The subprojects inside reports/ pick up parent conventions only when they apply id("org.jbax.internal-conventions"), which needs one pluginManagement line in reports/settings.gradle.kts. Add the shared catalog plugin next to it when the nested build wants libs.<alias> from gradle/libs.versions.toml:
pluginManagement { includeBuild("../parent/build-logic") }
plugins { id("org.jbax.shared-catalogs") }
rootProject.name = "reports"
include(":reports-api", ":reports-cli")That plugin also registers java toolchain downloads, so versions stay in the catalog and no settings file declares a toolchain resolver. Use ./gradlew buildNestedBuilds to build every nested build in one command, or pass -Preactor.nested.builds=false to leave them out of a run.
Keep subproject names inside a nested build distinct from the top-level module names, otherwise the IDE shows two projects with the same name.
After adding projects, moving folders around, or upgrading gradle, you can verify everything is wired up properly using the audit tasks in reactor-conventions.gradle.kts:
./gradlew checkReactorHealth
./gradlew auditBuildSystemSample output:
--- Build System Audit Result ---
Active Gradle Version: 9.9.3
[OK] 'libs' Catalog: Resolved (4 libraries)
[OK] All modules have healthy infrastructure links!
-----------------------------------
When your projects are separate git repositories and you want a snapshot file recording the current branch and commit hash of every repo, run:
./gradlew generateManifestThis writes a timestamped TOML file inside the folder configured by reactor.publish.manifest.dir, like parent/manifests/manifest-20261125-1430.toml.
By default, gradle runs with a 4 GB heap configured in gradle.properties. If you need more memory for a heavy build without editing checked-in files:
GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx8g" ./gradlew buildNOTE: always pass
-Dorg.gradle.jvmargs=...here. A plain-Xmx8ginGRADLE_OPTSonly changes the tiny launcher process and won't resize the actual gradle daemon.
To upgrade gradle across parent/ and all generated views:
./gradlew wrapper --gradle-version latest --distribution-type bin
./gradlew :wrapper
./gradlew help --warning-mode all
./gradlew --stopNext up: Fast builds, named profiles, and binary dependencies.
This page was generated from docs/templates/README.md using ./gradlew :render-docs.


