Skip to content

Attach per-version properties to parameterized Gradle versions#51

Merged
ogolberg merged 2 commits intomainfrom
gradle-version-properties
May 8, 2026
Merged

Attach per-version properties to parameterized Gradle versions#51
ogolberg merged 2 commits intomainfrom
gradle-version-properties

Conversation

@ogolberg
Copy link
Copy Markdown
Member

@ogolberg ogolberg commented May 7, 2026

Summary

  • Adds a @GradleVersion(version, properties = [@Property(key, value)]) sub-annotation so each Gradle version in a parameterized test can carry extra metadata (e.g. a matching Kotlin version to pair with an older Gradle).
  • Both @TestKit and @ParameterizedWithGradleVersions gain a versions: Array<GradleVersion> field alongside the existing Array<String> form. Resolution priority: method versions → method value → class versions → class gradleVersions. Fully backward compatible.
  • GradleVersionArgument carries the properties; ProjectKey includes them so the per-version TestProject cache stays correct.
  • TestProject.property(key) exposes the metadata to test bodies.
  • Display names include the properties, e.g. project(gradle: 8.6 [kotlin=1.9.24]).

Example

@TestKit(versions = [
    GradleVersion(version = "8.6", properties = [Property(key = "kotlin", value = "1.9.24")]),
    GradleVersion(version = "8.7", properties = [Property(key = "kotlin", value = "2.0.0")])
])
class MyTest {
    @ParameterizedWithGradleVersions
    fun test(project: TestProject) {
        val kotlin = project.property("kotlin")
        // use `kotlin` to template the build file, pick a plugin version, etc.
    }
}

Test plan

  • New GradleVersionPropertiesIntegrationTest exercises the feature and passes
  • Existing TestKitIntegrationTest still uses the legacy gradleVersions = [...] form unchanged
  • Confirm display names render properties: project(gradle: 8.6 [kotlin=1.9.24])
  • CI green across the :junit5 module

🤖 Generated with Claude Code

ogolberg added 2 commits May 7, 2026 12:41
Introduce @GradleVersion(version, properties = [@Property(...)]) so tests
can attach metadata (e.g. a minimum Kotlin version) to each parameterized
Gradle version. Both @testkit and @ParameterizedWithGradleVersions accept
the richer form alongside the existing Array<String> path, and
TestProject.property(key) exposes the values to test bodies.

Generated with Claude Code
Generated with Claude Code
@ogolberg ogolberg marked this pull request as ready for review May 8, 2026 15:07
@ogolberg ogolberg merged commit a336b54 into main May 8, 2026
1 check passed
@ogolberg ogolberg deleted the gradle-version-properties branch May 8, 2026 15:07
ogolberg added a commit that referenced this pull request May 8, 2026
## Summary
- Documents the `@GradleVersion` / `@Property` parameterization
introduced in #51, including the `project.property(key)` accessor and
the per-version display-name format.
- Deprecates `@TestKit.gradleVersions` and
`@ParameterizedWithGradleVersions.value` in favor of the `versions`
array (`ReplaceWith("versions")`), and notes the resolution priority in
the README.

## Test plan
- [ ] `./gradlew :junit5:compileKotlin` succeeds with no new warnings
- [ ] Full CI green (existing `TestKitIntegrationTest` still exercises
the legacy `gradleVersions = [...]` form)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

1 participant