Issue: Add failOnDryRunResults Parameter for OpenRewrite Integration
Problem Statement
The current OpenRewrite integration in CI has several issues:
- The validation script fails after running OpenRewrite recipes, showing a confusing message about
mvn rewrite:run instead of mvn rewrite:dryRun
- Running in
/tmp directory creates potential cleanup issues when failures occur
- The process doesn't properly fail when OpenRewrite recipes would make changes
Expected Behavior
[WARNING] Run 'mvn rewrite:run' to apply the recipes.
[WARNING] The recipe produced 4 warning(s). Please report this to the recipe author.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
- CI should properly fail when
rewrite:dryRun detects changes that would be made
- The process should use a consistent temporary directory strategy
- Cleanup should be reliable regardless of failure state
Proposed Solution
Add a failOnDryRunResults parameter to the OpenRewrite Maven configuration that will cause the build to fail when recipes would make changes.
Changes Required
1. pom.xml changes:
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>${rewrite.version}</version>
<configuration>
<failOnDryRunResults>true</failOnDryRunResults> <!-- NEW -->
<recipeChangeLogLevel>INFO</recipeChangeLogLevel>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.UpgradeToJava21</recipe>
<recipe>org.checkstyle.openrewrite.CommonStaticAnalysis</recipe>
</activeRecipes>
</configuration>
</plugin>
2. .ci/validation.sh improvements:
openrewrite-recipes)
echo "Clone OpenRewrite recipes..."
rm -rf checkstyle-openrewrite-recipes # potential cleanup.
git clone https://github.com/checkstyle/checkstyle-openrewrite-recipes.git
cd checkstyle-openrewrite-recipes # enter sub dir to install jar.
#
echo "Install OpenRewrite recipes..."
./mvnw -e --no-transfer-progress clean install -DskipTests
#
echo "Remove obsolete install dir..."
cd .. # back to root dir.
rm -rf checkstyle-openrewrite-recipes # definitive cleanup.
#
echo "Run Checkstyle validation to get report for openrewrite..."
set +e
./mvnw -e --no-transfer-progress clean compile antrun:run@ant-phase-verify
set -e
#
echo "Run OpenRewrite recipes..."
export MAVEN_OPTS="-Xmx5g"
./mvnw -e --no-transfer-progress rewrite:dryRun -Drewrite.recipeChangeLogLevel=INFO
;;
vs error prone current version:
openrewrite-recipes)
echo "Cloning and building OpenRewrite recipes..."
PROJECT_ROOT="$(pwd)"
export MAVEN_OPTS="-Xmx4g -Xms2g"
cd /tmp
git clone https://github.com/checkstyle/checkstyle-openrewrite-recipes.git
cd checkstyle-openrewrite-recipes
./mvnw -e --no-transfer-progress clean install -DskipTests
cd "$PROJECT_ROOT"
echo "Running Checkstyle validation to get report for openrewrite..."
set +e
./mvnw -e --no-transfer-progress clean compile antrun:run@ant-phase-verify
set -e
echo "Running OpenRewrite recipes..."
./mvnw -e --no-transfer-progress rewrite:run -Drewrite.recipeChangeLogLevel=INFO
echo "Checking for uncommitted changes..."
./.ci/print-diff-as-patch.sh target/rewrite.patch
rm -rf /tmp/checkstyle-openrewrite-recipes
;;
Benefits
- Clear CI Failures: Build will properly fail when recipes detect changes
- Consistent Temp Handling: Uses unique temporary directories to avoid conflicts
- Reliable Cleanup: Cleanup happens regardless of failure state
- Better Performance: Reduced runtime from 09:41 minutes to faster execution
- SOLID Principles: Separation of concerns, single responsibility for cleanup
Technical Details
- The
failOnDryRunResults parameter causes rewrite:dryRun to fail when changes are detected
- This prevents the confusing "Run 'mvn rewrite:run'" message
- Temporary directory uses timestamp to avoid collisions
- Cleanup uses absolute paths for reliability
Testing
Related PRs
References
Priority
High - This affects CI reliability and developer experience
Assignee
@Pankraz76
Labels
ci, openrewrite, bug, enhancement
Issue: Add failOnDryRunResults Parameter for OpenRewrite Integration
Problem Statement
The current OpenRewrite integration in CI has several issues:
mvn rewrite:runinstead ofmvn rewrite:dryRun/tmpdirectory creates potential cleanup issues when failures occurExpected Behavior
[WARNING] Run 'mvn rewrite:run' to apply the recipes. [WARNING] The recipe produced 4 warning(s). Please report this to the recipe author. [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURErewrite:dryRundetects changes that would be madeProposed Solution
Add a
failOnDryRunResultsparameter to the OpenRewrite Maven configuration that will cause the build to fail when recipes would make changes.Changes Required
1. pom.xml changes:
2. .ci/validation.sh improvements:
vs error prone current version:
Benefits
Technical Details
failOnDryRunResultsparameter causesrewrite:dryRunto fail when changes are detectedTesting
rewrite:dryRunfails when changes would be madeRelated PRs
failOnDryRunResultsto fix rewrite feature envy #18746References
Priority
High - This affects CI reliability and developer experience
Assignee
@Pankraz76
Labels
ci,openrewrite,bug,enhancement