Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
Get-ChildItem -Recurse -Depth 2 -Filter gradlew | ForEach-Object {
Push-Location $_.DirectoryName
Write-Host "Building in $($_.DirectoryName)..."
& ./gradlew rewriteDryRun
& ./gradlew rewriteDryRun --no-parallel --no-configuration-cache
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewriteDryRun can't be run in parallel or with the configuration cache.

if ($LASTEXITCODE -ne 0) {
throw "Build failed in $($_.DirectoryName)"
}
Expand Down
23 changes: 20 additions & 3 deletions java/build-logic/src/main/kotlin/zeroc-linting.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,26 @@ rewrite {
)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quality of life - so rewrite prints it's suggestions to the build output so they can be picked up.

// Set whether or not 'rewriteDryRun' should be considered 'failed' when it would make changes.
tasks.named("rewriteDryRun").configure {
rewrite.failOnDryRunResults = runningInCi
// Fail the build when 'rewriteDryRun' wants to make changes to the code,
// and print those required changes in the build output for clarity.
tasks.withType<org.openrewrite.gradle.RewriteDryRunTask>().configureEach {
doFirst {
// Delete the old report file if present
val reportFile = file(reportPath)
if (reportFile.exists()) {
reportFile.delete()
}
}

doLast {
if (file(reportPath).exists()) {
Comment on lines +50 to +59
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property reportPath is accessed but not defined in this file. This will cause a compilation error unless reportPath is a property of RewriteDryRunTask. Verify that reportPath exists on the task or define it explicitly.

Suggested change
doFirst {
// Delete the old report file if present
val reportFile = file(reportPath)
if (reportFile.exists()) {
reportFile.delete()
}
}
doLast {
if (file(reportPath).exists()) {
// Define the path to the rewrite dry run report file
val reportPath = project.layout.buildDirectory.file("rewrite/rewrite-dry-run.txt").get().asFile.toPath()
doFirst {
// Delete the old report file if present
val reportFile = reportPath.toFile()
if (reportFile.exists()) {
reportFile.delete()
}
}
doLast {
if (reportPath.toFile().exists()) {

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a property defined by the rewrite Task itself.

It's getter is defined here: https://github.com/openrewrite/rewrite-gradle-plugin/blob/363bbc7a63a2df4d8f78f33d6812e416ef9e77cf/plugin/src/main/java/org/openrewrite/gradle/RewriteDryRunTask.java#L32
To access them through gradle you omit the get prefix though.

print("\n\n" + java.nio.file.Files.readString(reportPath))

if (runningInCi) {
throw RuntimeException("Applying recipes would make changes. See logs for more details.")
}
}
}
}

// We always want to pass "-Xlint:all" when running 'javac'. This enables all its built-in lint checking.
Expand Down
2 changes: 2 additions & 0 deletions java/config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>

<module name="UnusedImports"/>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason not to check for this.

<module name="AvoidStarImport"/>
<module name="OneTopLevelClass"/>
<module name="NoLineWrap">
Expand Down