Fix #735: make the build compatible with the Gradle version of consumer builds
What
This makes the build files of this repository compatible with the Gradle version of consumer builds, so the gradle plugin can be resolved from this repository as a source control dependency again, and pins that scenario with a functional test. Fixes #735.
Why
When a consumer build declares this repository as a source control dependency as in #735, Gradle evaluates the build files of this repository with the Gradle version of the consumer build, not with the wrapper version of this repository. With a modern consumer build such as the Gradle 8.6 of the issue report, evaluation fails with:
Could not find method enabled() for arguments [true] on Report xml of type org.gradle.api.reporting.internal.TaskGeneratedSingleFileReport.
and that failure is what surfaces in the consumer as the ResolveException: Could not resolve all dependencies for configuration ':...:detachedConfiguration80' of the issue report.
Three spots in the build files only worked on older Gradle versions:
jacocoTestReportused the removedxml.enabled truemethod-call syntax;xml.required = truedoes the same thing and works since Gradle 7.1, so this repository's own builds on the 7.6.2 wrapper behave as before- the cli module applied shadow 6.1.0 through the legacy buildscript classpath plus
apply plugin:; 6.1.0 referencesorg.gradle.api.plugins.MavenPlugin, which modern Gradle removed. It now comes through the plugins DSL at 7.1.2, the last version that resolves and works on both Gradle 7.6.x and 8.x - the buildscript repositories referenced the end-of-life jcenter(), now mavenCentral()
How
The PR consists of two commits:
- the first (d1dd29c0) carries the build file changes above
- the second (1853ed0a) adds the regression test, because the fix shipped without a test that exercises this scenario and nothing would otherwise catch a regression when the build files move again
The new functional test reproduces the report of #735: it copies this repository (without .git and build outputs) into the functional test workspace, wires the copy as an included build in the pluginManagement block of a small consumer project that applies the plugin, and runs the consumer build through TestKit with withGradleVersion("8.6"), the Gradle version of the issue report. Gradle evaluates the copied build files with that consumer version exactly like a source control dependency.
Tests
- without the build file fixes, the new functional test fails with the
enabled()error above (verified locally by temporarily checking out the master versions ofbuild.gradleandcli/build.gradle) - with the fixes, the consumer build succeeds and
:openAPIStyleValidatorreportsSUCCESS
./gradlew build is green with JDK 17.
Summary by cubic
Fixes #735 by making the build files compatible with the Gradle version of consumer builds, so the plugin can be resolved as a source control dependency again.
- Replaces the removed
xml.enabled truesyntax withxml.required = truefor JaCoCo reports. - Moves the shadow plugin to the plugins DSL in the
climodule and bumps it to 7.1.2, which works on both Gradle 7.6.x and 8.x. - Replaces the end-of-life
jcenter()withmavenCentral()in the buildscript repositories.
Tests
- Adds a functional test that evaluates the build files with Gradle 8.6 (the version from the issue report) through an included build and asserts the validation task succeeds.
- Without the build file fixes, the new test fails with the
enabled()error reported in #735. ./gradlew buildpasses with JDK 17.