[BUG][KOTLIN] build.gradle generated with idea=true fails on Gradle 9 (testSourceDirs)

未关闭
#25,572 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Grinv 已经在做这个了。

开始于 2026年11月6日。

  • #25573 来自 @Grinv —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
15/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
kotlin
领域
build-system

调研方向

Read kotlin-client/build.gradle.mustache and inspect how its idea module configures test source directories. The report identifies replacing testSourceDirs with testSources.from(file('src/test/kotlin')) and gives Gradle 7.6.2 and 9.8.2 as compatibility points. A linked pull request, #25573, is already open.

由索引模型根据 Issue 内容生成。

描述

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

With idea=true, kotlin-client/build.gradle.mustache adds an idea { module { ... } } block that sets testSourceDirs. Gradle 8.14 warns that the property is deprecated ("scheduled to be removed in Gradle 9.0. Please use the testSources property instead"), and Gradle 9 removed it, so the generated project fails to configure. The same project builds on Gradle 8.14, and without idea=true it builds on 9.

openapi-generator version

7.27.0, and master at d15b0164 (7.28.0-SNAPSHOT).

OpenAPI declaration file content or url

modules/openapi-generator/src/test/resources/3_0/petstore.yaml from this repo (validate reports no issues).

Generation Details
java -jar openapi-generator-cli.jar generate -g kotlin \
  -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
  -o out --additional-properties=idea=true
Steps to reproduce

Run gradle compileKotlin in out with Gradle 9.8.2:

* Where:
Build file '.../build.gradle' line: 59

* What went wrong:
Could not get unknown property 'testSourceDirs' for object of type org.gradle.plugins.ide.idea.internal.IdeaModuleInternal.

Expected: it configures and compiles.

Related issues/PRs

#22084, fixed for the Java templates in #24649.

Suggest a fix

testSources.from(file('src/test/kotlin')) instead of testSourceDirs += file('src/test/kotlin'). testSources exists since Gradle 7.4 (tested on 7.4, 7.6.2, 8.14 and 9.8.2; it fails on 7.3), and the oldest wrapper the template ships is 7.6.2 (for jvm-volley). PR to follow.

主要语言
Java
星标
26.9k
派生
7.8k
平均合并
2 天 10 小时
30 天内合并 PR
180

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenAPITools/openapi-generator 的其他 Issue

查看 OpenAPITools/openapi-generator 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。