resolver · daukle/maven · 1.7.1

daukle/maven

The resolver. It turns group:artifact:version coordinates into the pinned url and sha256 blocks a toolchain takes, by walking Maven POMs itself. It compiles nothing and runs nothing.

It is the first thing in daukle that resolves: every other acquisition in the system arrives already pinned by whoever wrote the manifest, and this one starts from a coordinate and ends with a digest it computed.

Declaring it

[plugins]
maven = "daukle/maven@^1"

[toolchains.maven]
coordinates     = ["org.slf4j:slf4j-api:1.7.36"]
testCoordinates = ["org.junit.jupiter:junit-jupiter:5.10.1"]
daukle maven:list                 # resolve only, no downloads
daukle maven:resolve --resolve    # resolve, fetch, hash

That is all: daukle loads the committed daukle/maven/classpath.lua by itself (daukle 0.15.0 or later), so nothing is added to daukle.lua. Delete it and the next resolve writes it again.

Keys

keymeaning
coordinatesa list of group:artifact:version, required unless resolve supplies a closure
testCoordinatesoptional, the test-only ones
versionsversions by name, which a coordinate names as ${name}, so one version is written once
strategy"highest" (Gradle's rule, the default) or "nearest" (Maven's)
repositorydefaults to Maven Central
forwhich toolchain the generated blocks name, default "java"
resolveoptional, a list of independent closures, each with its own repository and key
platformsoptional, BOM coordinates whose versions a bare group:artifact takes and which raise a lower version below them, as Gradle's platform() does
enforcedPlatformsoptional, BOM coordinates whose versions are forced, as Gradle's enforcedPlatform() does

A second repository, and a second key

One repository is enough until a project needs two. A Gradle build applies plugins from the Plugin Portal and compiles against Central, and Central answers 404 for a plugin marker. Each [[toolchains.maven.resolve]] entry is an independent closure with its own repository and its own into, which names the toolchain key its pins are appended to:

[toolchains.maven]
for = "gradle"
coordinates = ["org.slf4j:slf4j-api:1.7.36"]

[[toolchains.maven.resolve]]
repository = "https://plugins.gradle.org/m2"
coordinates = ["io.github.intisy.github-gradle:io.github.intisy.github-gradle.gradle.plugin:1.8.2.1"]
into = "pluginClasspath"

into has no default: a closure that lands on a key nothing reads downloads everything and changes nothing. Two resolutions appending to one key of one toolchain are refused by name.

To give one module, or one Gradle included build, a classpath of its own, write into as the path to the key:

[[toolchains.maven.resolve]]
coordinates = ["com.google.code.gson:gson:2.10.1"]
for = "gradle"
into = ["modules", "tools/core", "classpath"]

strategy is not a preference

Gradle settles a version conflict by taking the highest version and Maven the nearest. On a real library the two disagree about six of twenty modules, and they differ in set membership too. A project migrating onto the wrong rule compiles, passes and ships against dependencies its author never chose.

It is a key rather than a guess: a daukle project has no pom.xml and no build.gradle left to infer the old tool from.

Generated data never touches the file you wrote

maven:resolve writes Lua, not TOML. A TOML fragment would have to be pasted into daukle.toml, mixing generated rows into the one file you maintain by hand. The Lua fragment is loaded by daukle instead, it is committed, and it appends, so a classpath entry you wrote by hand survives beside the resolved ones.

The test closure

testCoordinates produces a second, independent resolve rooted on the compile coordinates plus the test ones. The generated testClasspath block carries only what the compile closure lacks.

A module the two closures resolve differently is refused by name. A toolchain reaches a test through classpath and then testClasspath, so the compile entry would win and the tests would run against a version neither closure chose, with nothing reporting it.

What it does not do

Version ranges and snapshots are refused by name: both are decided by whatever a registry holds at the moment it is read, and daukle pins. Classifiers and non-jar types are dropped.

Gradle module metadata is not read. Gradle prefers a .module file over a POM and can select different artifacts from it. On the test side that is org.apiguardian:apiguardian-api, which a POM declares at compile scope while the .module lists it under apiElements only, so this resolver's test closure matches Gradle's test compile classpath and is one jar larger than its test runtime one.