Excavator: Migrate Groovy nebula test SlsPackagingCompatibilityIntegrationSpec to the new Java Junit framework#1506
Open
svc-excavator-bot wants to merge 10 commits intodevelopfrom
Conversation
59d9473 to
602cca0
Compare
74caafb to
7d0f914
Compare
c6f9d56 to
7815b8f
Compare
b5ce34d to
9cc5305
Compare
…rationSpec` to the new Java Junit framework
b22ca68 to
7849d8e
Compare
FinlayRJW
reviewed
Feb 10, 2026
| /** | ||
| * sls-packaging is creating a configuration as part of a task input, which is happening far too late. | ||
| * Once gradle has done a resolution, it will not look at any new Configurations that have popped up | ||
| * since then. See https://github.com/palantir/gradle-consistent-versions/pull/1443 for more details. |
Contributor
There was a problem hiding this comment.
this is now fixed in sls-packaging in palantir/sls-packaging#1881
src/test/java/com/palantir/gradle/versions/SlsPackagingCompatibilityIntegrationTest.java
Show resolved
Hide resolved
…work-36debc64a3cf516f
check-unused-constraints
error-prone-apply-suppress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
excavator is a bot for automating changes across repositories.
Changes produced by the roomba/migrate-gradle-testing-junit-framework check.
A formatted diff between the old and new test has been generated at test-migration-notes/SlsPackagingCompatibilityIntegrationSpec.html)
To view the rendered diff, copy the branch name above, click here, and then replace the BRANCH_NAME part of the URL with the branch name.
🤖 🤖 This PR was created using Claude-code 🤖 🤖
Claude Execution Message
Claude finished running successfully.
Perfect! Let me create a final summary of the migration:
Migration Summary
I've successfully migrated the test class
SlsPackagingCompatibilityIntegrationSpec.groovytoSlsPackagingCompatibilityIntegrationTest.java. Here's what was accomplished:Key Changes
Framework Migration:
Test Structure:
where:block to@AdditionallyRunWithGradleannotation'#gradleVersionNumber can consume...'to Java'scan_consume_recommended_product_dependencies_project()Plugin Configuration:
com.palantir.sls-packaging:gradle-sls-packaging:7.31.0togradlePluginForTestinginbuild.gradle.plugins().add()API instead ofapply plugin:statements.addWithoutApply()for the sls-java-service-distribution pluginVersion Configuration:
@IgnoreIfAssertion Changes:
assertThat(result).task(taskPath).succeeded()Files Modified
/repo/src/test/java/com/palantir/gradle/versions/SlsPackagingCompatibilityIntegrationTest.java/repo/build.gradle- added gradlePluginForTesting dependency/repo/src/test/groovy/com/palantir/gradle/versions/SlsPackagingCompatibilityIntegrationSpec.groovy- added delineator comments/repo/test-migration-errors.md- documentation of issues and fixesCompilation Status
✅ The test compiles successfully without errors or warnings.
All delineator comments from the original Groovy file have been preserved in the new Java test to assist with human review.
Claude Code Metrics
Migration Notes
Test Migration Errors and Fixes
This document tracks errors encountered during the migration of
SlsPackagingCompatibilityIntegrationSpec.groovytoSlsPackagingCompatibilityIntegrationTest.java.First Pass Issues
Issue 1: Plugins API doesn't support versioned plugins with
addWithoutApplyError:
Original Code:
Fix:
The
addWithoutApply()method only accepts a plugin ID, not a version. For external plugins that require versions:gradlePluginForTestinginbuild.gradlewith the specific versionaddWithoutApply(pluginId)without the version parameterWhat I learned: The testing framework manages plugin versions through the
gradlePluginForTestingconfiguration, not through theplugins()API. This ensures that all test runs use the same plugin versions consistently.Issue 2: MavenRepo uses
path()noturi()Error:
Original Code:
Fix:
What I learned: The new framework's
MavenRepoclass exposespath()which returns aPathobject, noturi(). When using this in string formatting withfile:///, thePathis automatically converted to a string representation.Issue 3: InvocationResult doesn't expose
tasks()methodError:
Original Code (Groovy):
Attempted Fix:
Actual Fix:
The
InvocationResultclass doesn't expose atasks()method or access to the underlyingBuildResult.getTasks(). Instead, check each task individually:What I learned: The testing framework encourages explicit task assertions rather than filtering all tasks. This makes tests more readable and failures more specific. The framework intentionally doesn't expose internal Gradle TestKit details.
Issue 4: Error Prone check prevents
apply plugin:in text blocksError:
Original Code:
Fix:
What I learned: The testing framework ships with Error Prone checks that enforce best practices. The
GradleTestPluginsBlockcheck prevents usingapply plugin:orplugins { }blocks inappend()calls, instead requiring use of the structured.plugins().add()API. This ensures:Second Pass Review
Observation 1: @IgnoreIf annotation handling
Original Groovy Code:
Migrated Code:
The
@IgnoreIfannotation from Spock doesn't have a direct equivalent in the new framework for version-conditional test execution. However, the original test was skipping Gradle 9, but I've added Gradle 9.1.0 to the@AdditionallyRunWithGradleannotation.Decision: Since the issue described in the
@IgnoreIfwas about sls-packaging creating configurations too late in Gradle 9, and we're adding Gradle 9.1.0 explicitly in the test, this suggests either:The test will run on Gradle 9.1.0 and fail if the issue still exists, which is the desired behavior for a compatibility test.
Observation 2: Text block formatting
All text blocks follow the best practice of starting content immediately after
"""with no leading newline, as recommended in the testing guide.Observation 3: Plugin chaining
The code properly chains
.plugins().add()calls as recommended:This is more readable than:
Third Pass - Version Configuration Correction
Issue 5: Incorrect Gradle version configuration
Original Code:
Problem:
The original Groovy test used
GRADLE_VERSIONSwhich includes["7.6.4", "8.8", "8.14.3", "9.1.0"], but had an@IgnoreIfthat skipped tests on Gradle 9. I initially included 9.1.0 in the migrated test, which contradicted the original test's intent.Fix:
What I learned:
gradle-test-versions.ymlfor global version configuration (currently only 8.14.3)@AdditionallyRunWithGradleshould add versions that were in the original test but aren't in the global config@IgnoreIffor certain versions, those versions should not be included in@AdditionallyRunWithGradleFourth Pass - Code Style Improvements
Improvement 1: Combined buildGradle().append() calls
Before:
After:
Reason: Following the testing guide's best practice to "Combine
buildGradle().append()calls: Use a single append with one text block, not multiple calls." This makes the code more concise and easier to read.Summary
The migration successfully converted a Groovy/Spock test to a Java/JUnit 5 test using the new testing framework. Key learnings:
gradlePluginForTestinginbuild.gradle.plugins().add(),.appendProperty(), etc.) should always be used instead of manual text manipulation@AdditionallyRunWithGradlerather than Spock's data tablesTo enable or disable this check, please contact the maintainers of Excavator.