daukle/gradle
The Gradle toolchain. It generates the build file Gradle reads, provisions Gradle and a JDK, and runs Gradle against the generated project. Your repository holds daukle.toml and sources, and no build.gradle, no settings.gradle, no gradlew and no wrapper properties.
Declaring it
[plugins]
maven = "daukle/maven@^1"
gradle = "daukle/gradle@^1"
[toolchains.maven]
coordinates = ["org.slf4j:slf4j-api:1.7.36"]
testCoordinates = [
"org.junit.jupiter:junit-jupiter:5.10.1",
"org.junit.platform:junit-platform-launcher:1.10.1",
]
for = "gradle"
[toolchains.gradle]
release = "8"
Keys
| key | meaning |
|---|---|
version | which Gradle to provision, defaulting to 8.13. Forty-five are pinned, 7.2 to 9.8.2, and one it does not pin is refused by name with the range and the pins of its own major line. 7.2 is the floor, and asking for less says why: 7.0 to 7.1.1 fail to compile and test on the oldest JDK available here |
jdk | which JDK, through daukle/java's table, defaulting to 17 |
release | the Java source and target level |
sourcesJar | true adds Gradle's sources jar, which gradle:sources-jar builds |
sourceSets | extra source sets, keyed by name, each with its own roots and dependency keys. test = true makes one a test set that sees main and runs as its own task. Gradle's testing { suites {} } is not used, because every suite but the built-in one adds a JUnit dependency a build with no repository cannot resolve |
main | the class gradle:run runs. It also applies Gradle's application plugin, which is where a packaging plugin reads Main-Class from |
sourceRoot, resourceRoot, testSourceRoot, testResourceRoot | the usual defaults. Each takes one directory or a list of them, so generated sources can sit beside written ones; { buildOutput = "generated/x" } names a directory under the build directory, wherever daukle put it |
classpath, testClasspath | pinned entries, normally written by daukle/maven, rendering implementation and testImplementation |
compileOnly, runtimeOnly, testCompileOnly, testRuntimeOnly | the Gradle configurations of the same names. compileOnly is not on the runtime classpath and runtimeOnly is not on the compile classpath, which is why they are separate keys rather than one |
annotationProcessor, testAnnotationProcessor | javac's -processorpath, which is not the compile classpath. A processor usually wants its annotations on compileOnly too, and naming the same jar in both is correct |
api, compileOnlyApi | the two configurations java-library provides. Declaring either switches that file to java-library, for that module alone. api is carried to a module that requires this one; classpath is not |
plugins | third-party Gradle plugins to apply, each a { id, version }. An entry with no version names a plugin an included build declares |
pluginClasspath | the pinned jars the versioned plugins are applied FROM, normally written by daukle/maven |
configure | one block per extension a plugin registers |
settingsPlugins, settingsPluginClasspath, settingsConfigure | the same three for plugins applied to Settings, such as a toolchain resolver convention. The classpath is normally written by daukle/maven with into = "settingsPluginClasspath" |
verbatim, settingsVerbatim | plain Gradle code copied into a project's build file or into the settings script, as a groovy or kotlin member: the escape hatch a migration fills with code no key covers yet, and every use prints a warning that it is coverage owed. verbatim sits at the top level, in modules.<name> and in builds.<dir>; settingsVerbatim at the top level and in builds.<dir> (Groovy only there). See AUTHORING.md |
tasks | Gradle task names to surface as daukle tasks. gradle:discover tells you which exist |
modules | per-module blocks, keyed by a name [modules] declares. A source root, main, requiresBuilds, sourceSets and every dependency configuration above belong here once a project has modules |
builds | included builds, Gradle's composite builds, keyed by the build's directory. A build declaring gradlePlugins, each a { id, implementationClass }, is a plugin build whose plugins a versionless plugins or settingsPlugins entry applies; one without is a library build. A block takes the source roots, release and every dependency configuration, and refuses any other key by name |
requiresBuilds | the library builds a project depends on, by name. With modules it goes in [toolchains.gradle.modules.<name>], and core's [modules.<name>] refuses it |
There is no key for the project's version: the version at the top of daukle.toml becomes Gradle's, so gradle:jar writes <name>-<version>.jar the way Gradle does when a build sets one.
Tasks
gradle:classes, gradle:test, gradle:jar, gradle:run, gradle:sources-jar, gradle:version and gradle:discover, plus one for every name in tasks: shadowJar becomes gradle:shadow-jar, plus one per test set: integrationTest becomes gradle:integration-test.
Gradle resolves nothing
The generated build declares no repository at all. Every dependency is an absolute path to an artifact daukle already fetched and verified. Gradle is handed files and never a coordinate, so there is no second resolver in the system and no chance of two answers.
Everything Gradle produces, including its own .gradle/ state directory, lands under build/daukle/gradle/. The project root is never written to.
Gradle 9 removed something nobody declares
A generated build using useJUnitPlatform() with file dependencies passes on Gradle 8.13 with a deprecation and fails outright on 9.6.0: Gradle 8 injected junit-platform-launcher by itself and 9 stopped. It is in no POM, so no resolver produces it.
This plugin refuses a test run whose classpath carries a platform engine without a matching launcher, and names the coordinate and the version to add. It pins no launcher of its own: a 1.14.4 launcher against a 1.10.1 engine dies outright, so a launcher is not forward compatible with an older engine and one default would be wrong for every project not on that platform.
A fat jar, with no repository and no Gradle
A third-party packaging plugin is applied from a jar daukle pinned, so a fat jar needs no new mechanism and no repositories {}:
[[toolchains.maven.resolve]]
repository = "https://plugins.gradle.org/m2"
for = "gradle"
into = "pluginClasspath"
coordinates = ["com.gradleup.shadow:shadow-gradle-plugin:9.3.2"]
[toolchains.gradle]
main = "com.example.Main"
tasks = ["shadowJar"]
[[toolchains.gradle.plugins]]
id = "com.gradleup.shadow"
version = "9.3.2"
[toolchains.gradle.configure.shadowJar]
enableAutoRelocation = true
relocationPrefix = "com.example.shaded"
daukle gradle:shadow-jar then writes a jar carrying your classes, every dependency's classes relocated under that prefix, and a Main-Class the application plugin supplied, which java -jar runs. maven:resolve must run before the plugins block is added, because a plugin is applied from a pinned jar and there is nothing to apply until one exists.
Several modules, one depending on another
[modules] is declared at the top level, because it is what a consumer resolves rather than anything a toolchain owns. Declaring one makes daukle write a settings.gradle including every module and a build file for each:
[modules.greeting]
[modules.app]
requires = ["greeting"]
[toolchains.gradle]
version = "8.13"
[toolchains.gradle.modules.app]
main = "com.example.App"
daukle gradle:run compiles greeting first, puts it on app's compile classpath as implementation project(':greeting') and runs app. A module name is its directory, with / between components: [modules."tools/core"] is Gradle's :tools:core, and a name written with : is refused with the / form to use instead. A module needs no toolchain block at all unless it overrides something: its sources default to <name>/src/main/java and its tests to <name>/src/test/java. Once a project declares modules, main, a source root and a classpath belong to a module and are refused project-wide, because applying them to every module at once is the silent version. plugins, configure, release and sourcesJar work in both places: a project-wide value reaches every module and a module's own adds to it or overrides it, as Gradle's subprojects {} and a project's own script do. Two modules declaring main is refused by name, and so is a requires naming no module, two modules requiring each other, or a module requiring itself.
This needs daukle 0.7.0. An older daukle does not publish the module list to a plugin at all, so the plugin refuses rather than quietly building only the root.
A plugin built in this repository
A build-logic directory holding a Gradle plugin is an included build. Describe it under builds and apply its plugin with no version:
[toolchains.gradle]
plugins = [{ id = "example.hello" }]
tasks = ["hello"]
[toolchains.gradle.builds."build-logic"]
gradlePlugins = [{ id = "example.hello", implementationClass = "com.example.logic.HelloPlugin" }]
daukle gradle:hello builds build-logic from source and runs the task its plugin registers. Nothing is written into build-logic/: its Gradle files are generated under build/daukle/gradle/included/. This needs daukle/gradle 1.9.0. A buildSrc directory has to be renamed first, to build-logic for example, because Gradle reserves that build name.
What it does not do
Build logic written as CODE is not modellable: a task with a body, a tasks.withType(...) that computes something, an if over a project property. A third-party plugin, a shared preset and an extension block are all fine, because each of those is data. A raw Groovy escape hatch is refused by name, because it readmits build.gradle through the back door with you editing Groovy inside a TOML string.
A module's plugins and configure tree are the project's rather than its own. An included build is one project, never a set of modules, and a task that generates a source file, such as a generateConfig with a doLast body, is build logic written as code in an included build too.