Excavator: Migrate Groovy nebula test SupportsSpotless622 to the new Java Junit framework
#1481
+1,981
−29
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/SupportsSpotless622.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.
Excellent! The migration is complete and successful. Let me provide a summary:
Migration Complete ✓
I've successfully migrated the test class
SupportsSpotless622.groovyfrom the Nebula/Spock framework to the new Java-based testing framework.What was done:
Added delineator comments to the original Groovy test file to help with review comparison
Created the migrated Java test at:
gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/SupportsSpotless622.groovygradle-palantir-java-format/src/test/java/com/palantir/javaformat/gradle/SupportsSpotless622.javaKey changes made:
palantir_java_format_plugin_works_with_spotless_6_22_0IntegrationTestKitSpecinheritance with@GradlePluginTestsannotationRootProjectproject.file().createEmpty(),project.buildGradle().overwrite(), etc.)GradlewExecutorusage (needed for classpath isolation)Resolved two compilation issues:
GradlewExecutor.javafromtest/groovytotest/javadirectory to fix compilation order@SuppressWarnings("GradleTestPluginsBlock")for the intentional use ofapply plugin:syntax with buildscript blocksVerified compilation - The migrated test compiles successfully
Documented all issues and fixes in
test-migration-errors.mdThe migrated test follows all the best practices from the testing guide and is ready for review!
Claude Code Metrics
Migration Notes
Test Migration Errors and Fixes
Migration: SupportsSpotless622.groovy → SupportsSpotless622.java
Error 1: GradlewExecutor not found during compilation
Error Message:
Root Cause:
GradlewExecutor.java was located in
src/test/groovy/directory but was needed by Java tests insrc/test/java/. Since Gradle compiles Java sources before Groovy sources in mixed projects, the Java compiler couldn't find GradlewExecutor.Fix:
Copied GradlewExecutor.java from
src/test/groovy/com/palantir/javaformat/gradle/tosrc/test/java/com/palantir/javaformat/gradle/so it would be compiled with other Java test sources and available during Java compilation phase.Learning:
In Gradle projects with both Java and Groovy, Java files in the groovy source directory are compiled during the compileTestGroovy phase, which runs AFTER compileTestJava. If Java tests need to reference these classes, they must be in the java source directory.
Error 2: Error Prone GradleTestPluginsBlock check violation
Error Message:
Root Cause:
The new testing framework includes Error Prone checks that enforce best practices. One check (
GradleTestPluginsBlock) detects when plugin blocks are written directly inoverwrite()orappend()calls instead of using the structured.plugins().add()API.However, in this specific test, the use of
overwrite()withapply plugin:syntax (notplugins {}block) is intentional because:buildscript {}blocks to load plugins via classpath dependenciesapply plugin:syntax is required after buildscript blocksFix:
Added
@SuppressWarnings("GradleTestPluginsBlock")with a comment explaining why the standard pattern doesn't apply:Learning:
While the testing framework provides Error Prone checks to enforce best practices, there are legitimate cases where suppression is appropriate. When suppressing, always add a comment explaining why the standard pattern cannot be used.
Second Pass Review
After completing the initial migration and ensuring compilation succeeded, I reviewed the test against the testing-guide.md to ensure all best practices were followed:
Check 1: Test Structure
✅ Test uses
@GradlePluginTestsannotation✅ Test name is in snake_case format
✅ Parameter injection used correctly (RootProject)
✅ @beforeeach properly structured
Check 2: File Manipulation
✅ Using
project.file("versions.props").createEmpty()for file creation✅ Using
project.buildGradle().overwrite()and.append()for build file manipulation✅ Using text blocks for multi-line strings (no string concatenation)
Check 3: Assertions
✅ Using AssertJ assertions (
assertThat(result.success()).isTrue())✅ Static import for AssertJ (
import static org.assertj.core.api.Assertions.assertThat)Check 4: Special Considerations
✅ Test correctly uses GradlewExecutor instead of GradleInvoker - this is intentional for special classpath handling as documented in GradlewExecutor's javadoc
✅ Removed Nebula-specific settings (
definePluginOutsideOfPluginBlock,keepFiles) as they are not needed in the new frameworkCheck 5: Delineator Comments
✅ All delineator comments from the original Groovy file were preserved in the Java file for review purposes
Summary
The migration was successful with two main issues encountered:
The final migrated test follows all testing framework best practices and compiles successfully.
To enable or disable this check, please contact the maintainers of Excavator.