Polish "automate protobuf generation in tests"

This moves the common proto plugin pieces into a shared groovy
plugin script.

Also, resolves an unrelated (but blocking) error about the
`spring-pulsar-cache-provider` module's `compileJava` task
depending on the `formatMain` task.
This commit is contained in:
Chris Bono
2025-03-28 01:44:21 -05:00
parent ed56a3941c
commit 1a4ee049a0
4 changed files with 33 additions and 41 deletions

View File

@@ -114,7 +114,10 @@ public class JavaConventionsPlugin implements Plugin<Project> {
private void configureSpringJavaFormat(Project project) {
project.getPlugins().apply(SpringJavaFormatPlugin.class);
project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8"));
project.getTasks().withType(Format.class, (format) -> {
format.setEncoding("UTF-8");
project.getTasks().named("compileJava", JavaCompile.class, format::mustRunAfter);
});
project.getPlugins().apply(CheckstylePlugin.class);
CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class);
checkstyle.setToolVersion("10.12.4");

View File

@@ -0,0 +1,27 @@
//file:noinspection GroovyUnusedAssignment
tasks.matching { (it.name "extractIncludeTestFixturesProto") }
tasks.matching { (it.name == "extractIncludeTestFixturesProto") }
tasks.matching { (it.name == "extractIncludeTestFixturesProto") }
tasks.named('extractIncludeProto') { enabled = false }
tasks.named('extractIncludeTestProto') { enabled = false }
tasks.matching { (it.name == "extractIncludeTestFixturesProto") }
.configureEach { enabled = false }
tasks.withType(io.spring.javaformat.gradle.tasks.CheckFormat).configureEach { task ->
task.source = project.files(
task.source.filter { file ->
!file.path.contains('build/generated/source/proto')
task.enabled = false
}
)
}
protobuf {
protoc {
artifact = libs.protobuf.protoc.get()
}
}

View File

@@ -1,5 +1,3 @@
import io.spring.javaformat.gradle.tasks.CheckFormat
plugins {
id 'org.springframework.pulsar.spring-module'
alias(libs.plugins.protobuf)
@@ -7,23 +5,7 @@ plugins {
description = 'Spring Pulsar Reactive Support'
tasks.named('extractIncludeProto') { enabled = false }
tasks.named('extractIncludeTestProto') { enabled = false }
tasks.withType(CheckFormat).configureEach { task ->
task.source = project.files(
task.source.filter { file ->
!file.path.contains('build/generated/source/proto')
task.enabled = false
}
)
}
protobuf {
protoc {
artifact = libs.protobuf.protoc.get()
}
}
apply from: '../gradle/proto-conventions.gradle'
dependencies {
api project (':spring-pulsar')

View File

@@ -1,5 +1,3 @@
import io.spring.javaformat.gradle.tasks.CheckFormat
plugins {
id 'org.springframework.pulsar.spring-module'
id 'java-test-fixtures'
@@ -8,24 +6,7 @@ plugins {
description = 'Spring Pulsar Core'
tasks.named('extractIncludeProto') { enabled = false }
tasks.named('extractIncludeTestProto') { enabled = false }
tasks.named('extractIncludeTestFixturesProto') { enabled = false }
tasks.withType(CheckFormat).configureEach { task ->
task.source = project.files(
task.source.filter { file ->
!file.path.contains('build/generated/source/proto')
task.enabled = false
}
)
}
protobuf {
protoc {
artifact = libs.protobuf.protoc.get()
}
}
apply from: '../gradle/proto-conventions.gradle'
dependencies {
api 'io.micrometer:micrometer-observation'
@@ -78,4 +59,3 @@ dependencies {
// Used by UserRecordDe/serializer in test fixtures
testFixturesApi 'com.fasterxml.jackson.core:jackson-databind'
}