diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 3d79ae390..9cbba2e89 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -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 if ($LASTEXITCODE -ne 0) { throw "Build failed in $($_.DirectoryName)" } diff --git a/java/build-logic/src/main/kotlin/zeroc-linting.gradle.kts b/java/build-logic/src/main/kotlin/zeroc-linting.gradle.kts index 2bbe8e391..1a27a9daf 100644 --- a/java/build-logic/src/main/kotlin/zeroc-linting.gradle.kts +++ b/java/build-logic/src/main/kotlin/zeroc-linting.gradle.kts @@ -44,9 +44,26 @@ rewrite { ) } -// 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().configureEach { + doFirst { + // Delete the old report file if present + val reportFile = file(reportPath) + if (reportFile.exists()) { + reportFile.delete() + } + } + + doLast { + if (file(reportPath).exists()) { + 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. diff --git a/java/config/checkstyle/checkstyle.xml b/java/config/checkstyle/checkstyle.xml index 5f62c8d8a..0155f07d1 100644 --- a/java/config/checkstyle/checkstyle.xml +++ b/java/config/checkstyle/checkstyle.xml @@ -97,6 +97,8 @@ + +