Skip to content
Draft
4 changes: 3 additions & 1 deletion .github/workflows/beam_PreCommit_Spotless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ jobs:
github_job: ${{ matrix.job_name }} (${{ matrix.job_phrase }})
- name: Setup environment
uses: ./.github/actions/setup-environment-action
- name: Fetch origin/master for Spotless ratcheting
run: git fetch origin master:refs/remotes/origin/master
- name: run Spotless PreCommit script
uses: ./.github/actions/gradle-command-self-hosted-action
with:
gradle-command: spotlessCheck checkStyleMain checkStyleTest :buildSrc:spotlessCheck
arguments: -PdisableSpotlessApply
arguments: -PdisableSpotlessApply -PspotlessRatchet
- name: Upload test report
uses: actions/upload-artifact@v7
with:
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ val useMirror = isCi && !mavenCentralMirrorUrl.isNullOrBlank()
plugins {
`java-gradle-plugin`
groovy
id("com.diffplug.spotless") version "5.6.1"
id("com.diffplug.spotless") version "7.2.1"
}

// Define the set of repositories required to fetch and enable plugins.
Expand Down Expand Up @@ -68,7 +68,7 @@ dependencies {

runtimeOnly("com.google.protobuf:protobuf-gradle-plugin:0.8.13") // Enable proto code generation
runtimeOnly("com.github.davidmc24.gradle.plugin:gradle-avro-plugin:1.9.1") // Enable Avro code generation. Version 1.1.0 is the last supporting avro 1.10.2
runtimeOnly("com.diffplug.spotless:spotless-plugin-gradle:5.6.1") // Enable a code formatting plugin
runtimeOnly("com.diffplug.spotless:spotless-plugin-gradle:7.2.1") // Enable a code formatting plugin
runtimeOnly("gradle.plugin.com.dorongold.plugins:task-tree:1.5") // Adds a 'taskTree' task to print task dependency tree
runtimeOnly("net.linguica.gradle:maven-settings-plugin:0.5")
runtimeOnly("gradle.plugin.io.pry.gradle.offline_dependencies:gradle-offline-dependencies-plugin:0.5.0") // Enable creating an offline repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1176,16 +1176,16 @@ class BeamModulePlugin implements Plugin<Project> {
// If compiled on older SDK, compile with JDK configured with compatible javaXXHome
// The order is intended here
if (requireJavaVersion.compareTo(JavaVersion.VERSION_11) <= 0 &&
project.findProperty('java11Home')) {
project.findProperty('java11Home')) {
forkJavaVersion = '11'
} else if (requireJavaVersion.compareTo(JavaVersion.VERSION_17) <= 0 &&
project.findProperty('java17Home')) {
project.findProperty('java17Home')) {
forkJavaVersion = '17'
} else if (requireJavaVersion.compareTo(JavaVersion.VERSION_21) <= 0 &&
project.findProperty('java21Home')) {
project.findProperty('java21Home')) {
forkJavaVersion = '21'
} else if (requireJavaVersion.compareTo(JavaVersion.VERSION_25) <= 0 &&
project.findProperty('java25Home')) {
project.findProperty('java25Home')) {
forkJavaVersion = '25'
} else {
logger.config("Module ${project.name} disabled. To enable, either " +
Expand Down Expand Up @@ -1455,6 +1455,12 @@ class BeamModulePlugin implements Plugin<Project> {
// command-line. This is useful for pre-commit which runs checkStyle separately.
def disableCheckStyle = project.hasProperty('disableCheckStyle') &&
project.disableCheckStyle == 'true'
project.tasks.withType(org.gradle.api.plugins.quality.Checkstyle).configureEach {
classpath = project.files()
exclude '**/generated-src/**'
exclude '**/generated-sources/**'
mustRunAfter project.tasks.matching { it.name.startsWith('generate') }
}
project.checkstyleMain.enabled = !disableCheckStyle
project.checkstyleTest.enabled = !disableCheckStyle

Expand All @@ -1476,12 +1482,16 @@ class BeamModulePlugin implements Plugin<Project> {
project.disableSpotlessCheck == 'true'
project.spotless {
enforceCheck !disableSpotlessCheck
if (project.hasProperty('spotlessRatchet')) {
ratchetFrom project.findProperty('spotlessRatchetFrom') ?: 'origin/master'
}
java {
licenseHeader javaLicenseHeader
googleJavaFormat('1.7')
googleJavaFormat('1.17.0')
target project.fileTree(project.projectDir) {
include 'src/*/java/**/*.java'
exclude '**/DefaultPackageTest.java'
exclude '**/module-info.java'
}
// For spotless:off and spotless:on
toggleOffOn()
Expand Down Expand Up @@ -2098,7 +2108,8 @@ class BeamModulePlugin implements Plugin<Project> {
} else {
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
if (it.version != null) { // bom-managed artifacts do not have their versions
if (it.version != null) {
// bom-managed artifacts do not have their versions
dependencyNode.appendNode('version', it.version)
}
dependencyNode.appendNode('scope', param.scope)
Expand Down Expand Up @@ -2465,7 +2476,8 @@ class BeamModulePlugin implements Plugin<Project> {
project.protobuf {
protoc {
// The artifact spec for the Protobuf Compiler
artifact = "com.google.protobuf:protoc:$protobuf_version" }
artifact = "com.google.protobuf:protoc:$protobuf_version"
}

// Configure the codegen plugins
plugins {
Expand Down Expand Up @@ -2547,7 +2559,8 @@ class BeamModulePlugin implements Plugin<Project> {
project.protobuf {
protoc {
// The artifact spec for the Protobuf Compiler
artifact = "com.google.protobuf:protoc:${GrpcVendoring_1_69_0.protobuf_version}" }
artifact = "com.google.protobuf:protoc:${GrpcVendoring_1_69_0.protobuf_version}"
}

// Configure the codegen plugins
plugins {
Expand Down Expand Up @@ -2745,7 +2758,8 @@ class BeamModulePlugin implements Plugin<Project> {
doLast {
def beamPythonTestPipelineOptions = [
"pipeline_opts": config.pythonPipelineOptions + (usesDataflowRunner ? [
"--sdk_location=${project.ext.sdkLocation}"]
"--sdk_location=${project.ext.sdkLocation}"
]
: []),
"test_opts": config.pytestOptions,
"suite": config.name,
Expand Down Expand Up @@ -3037,7 +3051,8 @@ class BeamModulePlugin implements Plugin<Project> {
doLast {
def beamPythonTestPipelineOptions = [
"pipeline_opts": config.pythonPipelineOptions + (usesDataflowRunner ? [
"--sdk_location=${project.ext.sdkLocation}"]
"--sdk_location=${project.ext.sdkLocation}"
]
: []),
"test_opts": config.pytestOptions,
"suite": config.name,
Expand Down
9 changes: 8 additions & 1 deletion runners/flink/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ apply plugin: 'com.diffplug.spotless'
* These java sources are included in the subproject's sources in order to compile against the different versions.
* We configure spotless here once in order to only check these java sources once.
*/
repositories {
mavenCentral()
}

spotless {
if (project.hasProperty('spotlessRatchet')) {
ratchetFrom project.findProperty('spotlessRatchetFrom') ?: 'origin/master'
}
java {
licenseHeader org.apache.beam.gradle.BeamModulePlugin.javaLicenseHeader
googleJavaFormat('1.7')
googleJavaFormat('1.17.0')
target project.fileTree(project.projectDir) { include 'src/*/java/**/*.java' }
}
}
9 changes: 8 additions & 1 deletion runners/spark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ apply plugin: 'com.diffplug.spotless'
* These java sources are included in the subproject's sources in order to compile against the different versions.
* We configure spotless here once in order to only check these java sources once.
*/
repositories {
mavenCentral()
}

spotless {
if (project.hasProperty('spotlessRatchet')) {
ratchetFrom project.findProperty('spotlessRatchetFrom') ?: 'origin/master'
}
java {
licenseHeader org.apache.beam.gradle.BeamModulePlugin.javaLicenseHeader
googleJavaFormat('1.7')
googleJavaFormat('1.17.0')
target project.fileTree(project.projectDir) { include 'src/*/java/**/*.java' }
}
}
2 changes: 1 addition & 1 deletion sdks/java/io/cassandra/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
configurations.all (Configuration it) -> {
// error-prone requires newer guava, don't override for annotation processing
// https://github.com/google/error-prone/issues/2745
if (it.name == "annotationProcessor" || it.name =="testAnnotationProcessor") {
if (it.name == "annotationProcessor" || it.name =="testAnnotationProcessor" || it.name.startsWith("spotless")) {
return
}
resolutionStrategy {
Expand Down
2 changes: 1 addition & 1 deletion sdks/java/io/hadoop-file-system/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ hadoopVersions.each {kv ->
configurations.all (Configuration it) -> {
// error-prone requires newer guava, don't override for annotation processing
// https://github.com/google/error-prone/issues/2745
if (it.name == "annotationProcessor" || it.name =="testAnnotationProcessor") {
if (it.name == "annotationProcessor" || it.name =="testAnnotationProcessor" || it.name.startsWith("spotless")) {
return
}
resolutionStrategy {
Expand Down
2 changes: 1 addition & 1 deletion sdks/java/io/hadoop-format/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ hadoopVersions.each {kv ->
configurations.all (Configuration it) -> {
// error-prone requires newer guava, don't override for annotation processing
// https://github.com/google/error-prone/issues/2745
if (it.name == "annotationProcessor" || it.name =="testAnnotationProcessor") {
if (it.name == "annotationProcessor" || it.name =="testAnnotationProcessor" || it.name.startsWith("spotless")) {
return
}
resolutionStrategy {
Expand Down
Loading