Skip to content

Conversation

@svc-excavator-bot
Copy link
Collaborator

@svc-excavator-bot svc-excavator-bot commented Nov 24, 2025

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.groovy from the Nebula/Spock framework to the new Java-based testing framework.

What was done:

  1. Added delineator comments to the original Groovy test file to help with review comparison

  2. Created the migrated Java test at:

    • Input: gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/SupportsSpotless622.groovy
    • Output: gradle-palantir-java-format/src/test/java/com/palantir/javaformat/gradle/SupportsSpotless622.java
  3. Key changes made:

    • Converted from Groovy/Spock to Java/JUnit 5
    • Changed test name from quoted string to snake_case: palantir_java_format_plugin_works_with_spotless_6_22_0
    • Replaced IntegrationTestKitSpec inheritance with @GradlePluginTests annotation
    • Used parameter injection for RootProject
    • Converted file operations to use the new framework APIs (project.file().createEmpty(), project.buildGradle().overwrite(), etc.)
    • Switched to AssertJ assertions
    • Used text blocks for multi-line strings
    • Preserved all delineator comments for review
    • Kept the special GradlewExecutor usage (needed for classpath isolation)
  4. Resolved two compilation issues:

    • Moved GradlewExecutor.java from test/groovy to test/java directory to fix compilation order
    • Added @SuppressWarnings("GradleTestPluginsBlock") for the intentional use of apply plugin: syntax with buildscript blocks
  5. Verified compilation - The migrated test compiles successfully

  6. Documented all issues and fixes in test-migration-errors.md

The migrated test follows all the best practices from the testing guide and is ready for review!

Claude Code Metrics

Metric Value
Total cost $0.6467434000000001
Total Duration (API) 115
Total Duration (WALL) 11080
Token usage 267127 (input), 321957 (output)

Migration Notes

Test Migration Errors and Fixes

Migration: SupportsSpotless622.groovy → SupportsSpotless622.java

Error 1: GradlewExecutor not found during compilation

Error Message:

error: cannot find symbol
    private GradlewExecutor executor;
            ^
  symbol:   class GradlewExecutor
  location: class SupportsSpotless622

Root Cause:
GradlewExecutor.java was located in src/test/groovy/ directory but was needed by Java tests in src/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/ to src/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:

error: [GradleTestPluginsBlock] Plugins must be added using .plugins().add() method.
Use gradleFile.plugins().add("plugin-id") instead.

Root Cause:
The new testing framework includes Error Prone checks that enforce best practices. One check (GradleTestPluginsBlock) detects when plugin blocks are written directly in overwrite() or append() calls instead of using the structured .plugins().add() API.

However, in this specific test, the use of overwrite() with apply plugin: syntax (not plugins {} block) is intentional because:

  1. The test uses buildscript {} blocks to load plugins via classpath dependencies
  2. The apply plugin: syntax is required after buildscript blocks
  3. This is testing a specific integration scenario with spotless and consistent-versions

Fix:
Added @SuppressWarnings("GradleTestPluginsBlock") with a comment explaining why the standard pattern doesn't apply:

@SuppressWarnings("GradleTestPluginsBlock") // Uses buildscript with apply plugin syntax intentionally

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 @GradlePluginTests annotation
✅ 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 framework

Check 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:

  1. Compilation order issue - Resolved by moving GradlewExecutor.java to the correct source directory
  2. Error Prone check enforcement - Resolved by appropriately suppressing the check with documentation

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.

@svc-excavator-bot svc-excavator-bot force-pushed the roomba/migrate-gradle-testing-junit-framework-85ccc7acc6893a2 branch from 254bd5b to cb1a693 Compare November 25, 2025 19:00
@svc-excavator-bot svc-excavator-bot force-pushed the roomba/migrate-gradle-testing-junit-framework-85ccc7acc6893a2 branch from cb1a693 to 82de253 Compare December 3, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants