swagger-api / swagger-api/swagger-core

[Bug]: [swagger-gradle-plugin] ResolveTask execution fails under Gradle 9.7.1+ (Kotlin 2.4.0 internal API accessibility change)

Open
#5,308 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog Bug
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

Issue Description
Executing tasks registered with io.swagger.v3.plugins.gradle.tasks.ResolveTask fails when running under Gradle 9.7.1, whereas the exact same task completes successfully under Gradle 9.7.0.

Gradle 9.7.1 upgraded the embedded Kotlin version to 2.4.0, which enforces strict compilation of Kotlin DSL scripts against a prebuilt public API JAR. As a result, internal Gradle APIs (org.gradle.internal.impldep.*) accessed by ResolveTask at runtime are no longer accessible during Kotlin DSL script execution, causing task execution to fail.

Environment
Plugin Name: io.swagger.core.v3.swagger-gradle-plugin
Plugin Version: 2.2.50 (also tested/reproduced on 2.2.55)
Gradle Version: 9.7.1 (Failing), 9.7.0 (Working)
JDK Version: OpenJDK 21
OS: Linux / macOS

Steps to Reproduce
Configure a Gradle project using Kotlin DSL (build.gradle.kts) with io.swagger.core.v3.swagger-gradle-plugin:2.2.50.
Register a OpenAPI spec generation task using ResolveTask:

import io.swagger.v3.plugins.gradle.tasks.ResolveTask
import io.swagger.v3.plugins.gradle.tasks.ResolveTask.Format.JSON
val swaggerClasspath = configurations.create("swaggerClasspath") {
    extendsFrom(configurations.runtimeClasspath.get())
}
tasks.register<ResolveTask>("generateSwagger") {
    group = "documentation"
    outputFileName = "openapi-spec"
    outputFormat = JSON
    openApiFile = file("src/main/resources/api-info.yaml")
    prettyPrint = true
    classpath = files(sourceSets["main"].output, swaggerClasspath)
    buildClasspath = classpath
    resourcePackages = setOf("com.example.rest")
    outputDir = layout.buildDirectory.dir("generated/api").get().asFile
    readAllResources = true
    sortOutput = true
}

Set gradle/wrapper/gradle-wrapper.properties to gradle-9.7.0-bin.zip and run ./gradlew generateSwagger. Result: Task completes successfully.

Update gradle/wrapper/gradle-wrapper.properties to gradle-9.7.1-bin.zip and re-run ./gradlew generateSwagger. Result: Task execution fails.

Expected Behavior
ResolveTask should execute cleanly and generate the OpenAPI specification file under Gradle 9.7.1+, matching the behavior in Gradle 9.7.0.

Actual Behavior / Stacktrace
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':<task_name>' (registered in build file '<repo_name>/build.gradle.kts').

Could not isolate parameters com.swagger.v3.plugins.gradle.tasks.ResolveTask_Decorated of signed type ResolveTask
org.gradle.internal.impldep.org.apache.commons.lang3.Validate

Technical Analysis & Root Cause
Gradle 9.7.1 Changes: Gradle 9.7.1 introduced embedded Kotlin 2.4.0. In Kotlin 2.4.0, Kotlin DSL script compilation changed to resolve only against the public Gradle API JAR instead of dynamically generating an internal API wrapper classpath.

Impact on ResolveTask: ResolveTask relies on shaded internal dependency packages (org.gradle.internal.impldep.*) or reflection against internal Gradle task parameters. Under Gradle 9.7.1, accessing these internal types causes reflection and classloader isolation failures during task parameter isolation and execution.

Current Workaround
Affected projects must cap the Gradle wrapper at Gradle 9.7.0 using version constraints:

// renovate.json5
packageRules: [
  {
    matchPackageNames: ['gradle'],
    matchManagers: ['gradle-wrapper'],
    allowedVersions: '<=9.7.0'
  }
]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with ResolveTask using the provided Kotlin DSL configuration, comparing gradle/wrapper/gradle-wrapper.properties at Gradle 9.7.0 and 9.7.1. Then inspect ResolveTask and its task-parameter dependencies, especially the org.gradle.internal.impldep access described in the report. Done means the generateSwagger task completes under Gradle 9.7.1+ and produces the OpenAPI specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.