JavaRCA: Java Recipe for Carefree dependency Administration

Modularization and Dependency Management in Java projects does not have to be a mess. Take a fresh and playful perspective at this topic with the concepts and tools available in and for modern Java.
Java Gradle Maven Renovate
Your Java program is made up of JAR files — the modular building blocks of your software. Most come from open-source libraries, which are easy to add: like jars full of delicious jam, free for the taking from public repositories. But over time, these sweet-looking dependencies carry a hidden cost. As libraries evolve, maintenance becomes a burden. In long-lived projects, dependency management often turns into a tangled mess — tedious, error-prone, and time-consuming. With a modern Java toolset, you can avoid that. The JavaRCA recipe provides a clear guideline to help you do just that.
Shelf filled with open-source Jars

Get Started: Clarify your choice of Dependency Definition notation

The JavaRCA recipe works with the common approaches to define dependencies in Java projects. For new projects, it's recommended to use the Java Module System for dependency definition, with Gradle as the build tool. If you rely on frameworks that don't yet support the Module System well, you may use Gradle plainly. If you prefer Maven – or if you work on an existing Maven-based project – you can use that too, with or without the Module System. What matters most is being intentional and aware of your setup.
Java Gradle Maven
 /* Java Module System¹ */

requires transitive
  de.javarca.model;
requires
  org.apache.commons.io;
       /* Gradle */

api(
  project(":javarca-model")
)
implementation(
  "commons-io:commons-io"
)
          <!-- Maven -->

<dependency>
  <groupId>de.javarca</groupId>
  <artifactId>javarca-model</artifactId>
  <version>${revision}</version>
</dependency>
<dependency>
  <groupId>commons-io</groupId>
  <artifactId>commons-io</artifactId>
</dependency>
¹If you use the Java Module System for dependency definition, you still need Gradle or Maven as build tool.
You use a GradleX plugin to bridge the Module System with one of the build tools.

The Recipe

Recipe for Carefree Dependency Management
  1. Decide for one method and define Dependencies between Modules in dedicated files
    Java
    Java Module System: . . <module-folder>/src/main/java/module-info.java
    Gradle
    Gradle: . . . . . . . . <module-folder>/build.gradle.kts
    Maven
    Maven:  . . . . . . . . <module-folder>/pom.xml
  2. Version management in a dedicated file
    Gradle
    Gradle: . . . . . . . . <bom-folder>/build.gradle.kts
    Warn
    Do not mix with 1.
    Maven
    Maven:  . . . . . . . . <bom-folder>/pom.xml
  3. Configure each build concern in a dedicated file
    Gradle
    Gradle: . . . . . . . . <plugins-folder>/<build-concern>.gradle.kts
    Warn
    Do not mix with 1.
    Maven
    Maven:  . . . . . . . . <configs-folder>/<build-concern>/pom.xml
  4. Conflict management in a dedicated file
    Gradle
    Gradle: . . . . . . . . <plugins-folder>/dependency-rules.gradle.kts
    Warn
    Do not mix with 1.
    Maven
    Maven:  . . . . . . . . <configs-folder>/dependency-rules/pom.xml
  5. Configure dependency analysis and make it a regular check
    Gradle
    Gradle: . . . . . . . . <plugins-folder>/quality-check.gradle.kts
    Maven
    Maven:  . . . . . . . . <configs-folder>/quality-check/pom.xml
  6. Configure Renovate or Dependabot for automatic update PRs
    Gradle
    Renovate: . . . . . . . renovate.json
    Maven
    Dependabot: . . . . . . .github/dependabot.yml

Video Series

What is a Java Module?
What is a Java Module?
Defining Dependencies between Modules
Defining Dependencies between Modules
Managing Versions of 3rd party Modules
Managing Versions of 3rd party Modules
Using a Build System to retrieve and build Modules
Using a Build System to retrieve and build Modules
Managing conflicting Modules
Managing conflicting Modules
Staying carefree by using dependency analysis
Staying carefree by using dependency analysis
Staying carefree through automated updates
Staying carefree through automated updates
The JavaRCA.de recipe
The JavaRCA.de recipe

Explore

Dive deeper into Java modularity and Gradle

Presentations

Support


Java and the Java logo are trademarks of the Oracle Corporation. Gradle and the Gradle logo are trademarks of Gradle Inc. Apache Maven and the Apache Maven logo are trademarks of the Apache Software Foundation. Dependabot and the Dependabot logo are trademarks of GitHub Inc. Renovate and the Renovate logo are trademarks of White Source Ltd. Site operated by onepiece.Software.