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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 0 additions & 7 deletions .gitattributes

This file was deleted.

3 changes: 2 additions & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: v2
clean: true
plugins:
- remote: buf.build/protocolbuffers/java:v30.2
out: src/main/java
out: build/generated/sources/bufgen
32 changes: 11 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ tasks.register<Exec>("licenseHeader") {
"--year-range",
project.findProperty("license-header.years")!!.toString(),
"--ignore",
"src/main/java/build/buf/validate/",
"build/generated/sources/bufgen/",
"--ignore",
"conformance/src/main/java/build/buf/validate/conformance/",
"conformance/build/generated/sources/bufgen/",
"--ignore",
"src/main/resources/buf/validate/",
)
Expand Down Expand Up @@ -109,43 +109,28 @@ tasks.register<Exec>("exportProtovalidateModule") {

tasks.register<Exec>("generateSources") {
dependsOn("exportProtovalidateModule")
description = "Generates sources for the bufbuild/protovalidate module sources to src/main/java."
description = "Generates sources for the bufbuild/protovalidate module sources to build/generated/sources/bufgen."
commandLine(buf.asPath, "generate", "--template", "buf.gen.yaml", "src/main/resources")
}

tasks.register<Exec>("generateConformance") {
dependsOn("configureBuf")
description = "Generates sources for the bufbuild/protovalidate-testing module to conformance/src/main/java."
commandLine(
buf.asPath,
"generate",
"--template",
"conformance/buf.gen.yaml",
"-o",
"conformance/",
"buf.build/bufbuild/protovalidate-testing:${project.findProperty("protovalidate.version")}",
)
}

tasks.register("generate") {
description = "Generates sources with buf generate and buf export."
dependsOn(
"generateTestSources",
"generateSources",
"generateConformance",
"licenseHeader",
)
}

tasks.withType<JavaCompile> {
dependsOn("generateTestSources")
dependsOn("generate")
if (JavaVersion.current().isJava9Compatible) {
doFirst {
options.compilerArgs = mutableListOf("--release", "8")
}
}
// Disable errorprone on generated code
options.errorprone.excludedPaths.set("(.*/src/main/java/build/buf/validate/.*|.*/build/generated/.*)")
options.errorprone.excludedPaths.set(".*/build/generated/.*")
if (!name.lowercase().contains("test")) {
options.errorprone {
check("NullAway", CheckSeverity.ERROR)
Expand Down Expand Up @@ -173,6 +158,11 @@ buildscript {
}

sourceSets {
main {
java {
srcDir(layout.buildDirectory.dir("generated/sources/bufgen"))
}
}
test {
java {
srcDir(layout.buildDirectory.dir("generated/test-sources/bufgen"))
Expand All @@ -183,7 +173,7 @@ sourceSets {
apply(plugin = "com.diffplug.spotless")
configure<SpotlessExtension> {
java {
targetExclude("src/main/java/build/buf/validate/**/*.java", "build/generated/test-sources/bufgen/**/*.java")
targetExclude("build/generated/sources/bufgen/build/buf/validate/**/*.java", "build/generated/test-sources/bufgen/**/*.java")
}
kotlinGradle {
ktlint()
Expand Down
3 changes: 2 additions & 1 deletion conformance/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
version: v2
clean: true
managed:
enabled: true
override:
- file_option: java_package_prefix
value: build
plugins:
- remote: buf.build/protocolbuffers/java:v30.2
out: src/main/java
out: build/generated/sources/bufgen
36 changes: 34 additions & 2 deletions conformance/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ plugins {
application
java
alias(libs.plugins.errorprone)
alias(libs.plugins.osdetector)
}

val buf: Configuration by configurations.creating

tasks.register("configureBuf") {
description = "Installs the Buf CLI."
File(buf.asPath).setExecutable(true)
}

val conformanceCLIFile =
Expand Down Expand Up @@ -39,14 +47,35 @@ tasks.register<Exec>("conformance") {
commandLine(*(listOf(conformanceCLIPath) + conformanceArgs + listOf(conformanceAppScript)).toTypedArray())
}

tasks.register<Exec>("generateConformance") {
dependsOn("configureBuf")
description = "Generates sources for the bufbuild/protovalidate-testing module to build/generated/sources/bufgen."
commandLine(
buf.asPath,
"generate",
"--template",
"buf.gen.yaml",
"buf.build/bufbuild/protovalidate-testing:${project.findProperty("protovalidate.version")}",
)
}

sourceSets {
main {
java {
srcDir(layout.buildDirectory.dir("generated/sources/bufgen"))
}
}
}

tasks.withType<JavaCompile> {
dependsOn("generateConformance")
if (JavaVersion.current().isJava9Compatible) {
doFirst {
options.compilerArgs = mutableListOf("--release", "8")
}
}
// Disable errorprone on generated code
options.errorprone.excludedPaths.set(".*/src/main/java/build/buf/validate/conformance/.*")
options.errorprone.excludedPaths.set(".*/build/generated/sources/bufgen/.*")
}

// Disable javadoc for conformance tests
Expand Down Expand Up @@ -81,7 +110,7 @@ tasks {
apply(plugin = "com.diffplug.spotless")
configure<SpotlessExtension> {
java {
targetExclude("src/main/java/build/buf/validate/**/*.java")
targetExclude("build/generated/sources/bufgen/**/*.java")
}
}

Expand All @@ -92,6 +121,9 @@ dependencies {

implementation(libs.assertj)
implementation(platform(libs.junit.bom))

buf("build.buf:buf:${libs.versions.buf.get()}:${osdetector.classifier}@exe")

testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

Expand Down

This file was deleted.

Loading