Skip to content

Fix #735: make the build compatible with the Gradle version of consumer builds - #815

Open
Inf1mum wants to merge 2 commits into
OpenAPITools:masterfrom
Inf1mum:fix/735-gradle-plugin-error
Open

Inf1mum wants to merge 2 commits into
OpenAPITools:masterfrom
Inf1mum:fix/735-gradle-plugin-error

Conversation

@Inf1mum

@Inf1mum Inf1mum commented Nov 15, 2026 •

Copy link
Copy Markdown

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:

  • jacocoTestReport used the removed xml.enabled true method-call syntax; xml.required = true does 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 references org.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 (d1dd29c) carries the build file changes above
  • the second (1853ed0) 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 of build.gradle and cli/build.gradle)
  • with the fixes, the consumer build succeeds and :openAPIStyleValidator reports SUCCESS

./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 true syntax with xml.required = true for JaCoCo reports.
  • Moves the shadow plugin to the plugins DSL in the cli module and bumps it to 7.1.2, which works on both Gradle 7.6.x and 8.x.
  • Replaces the end-of-life jcenter() with mavenCentral() 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 Error when adding Gradle plugin to project #735.
  • ./gradlew build passes with JDK 17.

Written for commit 1853ed0. Summary will update on new commits.

View guided diff

…ilds

What:
- Configure the jacoco test report with the required property instead
  of the removed enabled method-call syntax
- Move the shadow plugin to the plugins DSL of the cli module and bump
  it to 7.1.2, the last version that works on both Gradle 7.6.x and 8.x
- Replace the end-of-life jcenter() with mavenCentral() in the
  buildscript repositories

Why:
When a consumer build resolves the gradle plugin from this repository
as a source control dependency (issue OpenAPITools#735), Gradle evaluates the
build files of this repository with the Gradle version of the
consumer. With modern consumer builds such as the Gradle 8.6 of the
issue report this fails with 'Could not find method enabled() for
arguments [true] on Report xml' and shadow 6.1.0 references
org.gradle.api.plugins.MavenPlugin which was removed in Gradle 8.

How:
xml.required works since Gradle 7.1 and shadow 7.1.2 applied through
the plugins DSL resolves from the plugin portal on both Gradle 7.6.2
(the wrapper of this repository) and Gradle 8.x, so the source build
evaluates and the plugin resolves in consumer builds.

Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
What:
- Add a functional test that applies the plugin from this repository's
  build logic with a modern consumer build (the Gradle 8.6 of the issue
  report) through an included build and asserts the validation task
  succeeds

Why:
Issue OpenAPITools#735 reports that resolving the gradle plugin as a source control
dependency fails on modern consumer builds, because Gradle evaluates
this repository's build files with the Gradle version of the consumer.
The preceding fix commit shipped without a test that exercises this
scenario, so nothing would catch a regression when the build files move
again.

How:
The test 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, and runs the
consumer build through TestKit with withGradleVersion("8.6"). Without
the build file fixes this fails with 'Could not find method enabled()
for arguments [true] on Report xml', the error behind the
ResolveException of the issue report.

Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="cli/build.gradle">

<violation number="1" location="cli/build.gradle:3">
P1: Shadow 7.1.2 fails when applied with Gradle 8.x because it maps the removed `Jar.classifier` property. A Gradle 8.6 build that configures `:cli` fails during configuration; upgrade to a Gradle-8-compatible Shadow release such as 8.1.1.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread cli/build.gradle
@@ -1,5 +1,6 @@
plugins {
id "com.diffplug.spotless" version "6.25.0"
id 'com.github.johnrengelman.shadow' version '7.1.2'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Shadow 7.1.2 fails when applied with Gradle 8.x because it maps the removed Jar.classifier property. A Gradle 8.6 build that configures :cli fails during configuration; upgrade to a Gradle-8-compatible Shadow release such as 8.1.1.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At cli/build.gradle, line 3:

<comment>Shadow 7.1.2 fails when applied with Gradle 8.x because it maps the removed `Jar.classifier` property. A Gradle 8.6 build that configures `:cli` fails during configuration; upgrade to a Gradle-8-compatible Shadow release such as 8.1.1.</comment>

<file context>
@@ -1,5 +1,6 @@
 plugins {
     id "com.diffplug.spotless" version "6.25.0"
+    id 'com.github.johnrengelman.shadow' version '7.1.2'
 }
 
</file context>
Suggested change
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.github.johnrengelman.shadow' version '8.1.1'

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error when adding Gradle plugin to project

1 participant