Skip to content

SYSTEM Cited by 1 source

Gradle Module Metadata

Gradle Module Metadata is Gradle's own publication-metadata format (docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html) that ships alongside the standard Maven .pom file as a .module JSON file. Its purpose is to express dependency information that Maven POM cannot — most notably, multiple variants of the same module differentiated by attribute (e.g. JDK version, OS, classifier, usage attribute).

This page is a stub created for cross-referencing from sources/2026-05-08-netflix-scaling-archunit-with-nebula-archrules, where Module Metadata is load-bearing for how Nebula ArchRules publishes rule jars as a separate variant alongside the main library jar.

Why Maven POM isn't enough

A standard Maven publication has one main jar plus optional classifier jars (-sources, -javadoc, etc.). The classifier is just a string suffix; the POM doesn't carry semantics about when to use which classifier or which dependency configurations are valid for which.

Module Metadata adds:

  • Variants — a single module ID can publish multiple variants (e.g. apiElements, runtimeElements, arch-rules).
  • Attributes — each variant has attribute values (org.gradle.usage=java-runtime, org.gradle.usage=arch-rules, etc.) that the resolver uses to pick the right variant for the consuming configuration.
  • Capabilities — variants can declare what they provide, enabling conflict detection between alternative implementations.

Why Nebula ArchRules requires it

"This code and its dependencies will not be bundled with your main code. It is bundled into a separate Jar with the arch-rules classifier. When publishing, your library will publish this jar as a separate variant with the usage attribute set to arch-rules. This means that in order for downstream projects to use these rules, they must use Gradle Module Metadata for dependency resolution."sources/2026-05-08-netflix-scaling-archunit-with-nebula-archrules

The Nebula ArchRules Library Plugin publishes the archRules source set's compiled classes as a jar with the arch-rules classifier + the usage attribute = arch-rules. The Runner Plugin's per-source-set classpath construction (combining archRules configuration with runtimeClasspath) selects the arch-rules variant via attribute matching — a resolution that Maven POM cannot express.

Consumer adoption ceiling: organizations using Maven-only build systems, or older Gradle versions where Module Metadata isn't yet enabled by default, can't consume Nebula ArchRules without first migrating their dependency-resolution layer.

Adoption history (per Gradle docs)

  • Module Metadata was added to Gradle 5.3 (2019).
  • It became the default publication format for Java libraries in Gradle 6.0 (2019).
  • Gradle plugins / build tools that need attribute-based variant selection (Java toolchains, native targets, Kotlin Multiplatform) all rely on it.

Seen in

Last updated · 542 distilled / 1,571 read