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:
@@ -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");
|
||||
|
||||
27
gradle/proto-conventions.gradle
Normal file
27
gradle/proto-conventions.gradle
Normal 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()
|
||||
}
|
||||
}
|
||||
@@ -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')
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user