Skip to content

Commit b4c8064

Browse files
authored
Remove checked in generated code (#263)
Update codegen to generate to the build directory to minimize the code in this project and match other protovalidate projects. Upgrade to Gradle 8.13.
1 parent 68daeff commit b4c8064

File tree

1,705 files changed

+52
-577680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,705 files changed

+52
-577680
lines changed

.gitattributes

Lines changed: 0 additions & 7 deletions
This file was deleted.

buf.gen.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version: v2
2+
clean: true
23
plugins:
34
- remote: buf.build/protocolbuffers/java:v30.2
4-
out: src/main/java
5+
out: build/generated/sources/bufgen

build.gradle.kts

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ tasks.register<Exec>("licenseHeader") {
6464
"--year-range",
6565
project.findProperty("license-header.years")!!.toString(),
6666
"--ignore",
67-
"src/main/java/build/buf/validate/",
67+
"build/generated/sources/bufgen/",
6868
"--ignore",
69-
"conformance/src/main/java/build/buf/validate/conformance/",
69+
"conformance/build/generated/sources/bufgen/",
7070
"--ignore",
7171
"src/main/resources/buf/validate/",
7272
)
@@ -109,43 +109,28 @@ tasks.register<Exec>("exportProtovalidateModule") {
109109

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

116-
tasks.register<Exec>("generateConformance") {
117-
dependsOn("configureBuf")
118-
description = "Generates sources for the bufbuild/protovalidate-testing module to conformance/src/main/java."
119-
commandLine(
120-
buf.asPath,
121-
"generate",
122-
"--template",
123-
"conformance/buf.gen.yaml",
124-
"-o",
125-
"conformance/",
126-
"buf.build/bufbuild/protovalidate-testing:${project.findProperty("protovalidate.version")}",
127-
)
128-
}
129-
130116
tasks.register("generate") {
131117
description = "Generates sources with buf generate and buf export."
132118
dependsOn(
133119
"generateTestSources",
134120
"generateSources",
135-
"generateConformance",
136121
"licenseHeader",
137122
)
138123
}
139124

140125
tasks.withType<JavaCompile> {
141-
dependsOn("generateTestSources")
126+
dependsOn("generate")
142127
if (JavaVersion.current().isJava9Compatible) {
143128
doFirst {
144129
options.compilerArgs = mutableListOf("--release", "8")
145130
}
146131
}
147132
// Disable errorprone on generated code
148-
options.errorprone.excludedPaths.set("(.*/src/main/java/build/buf/validate/.*|.*/build/generated/.*)")
133+
options.errorprone.excludedPaths.set(".*/build/generated/.*")
149134
if (!name.lowercase().contains("test")) {
150135
options.errorprone {
151136
check("NullAway", CheckSeverity.ERROR)
@@ -173,6 +158,11 @@ buildscript {
173158
}
174159

175160
sourceSets {
161+
main {
162+
java {
163+
srcDir(layout.buildDirectory.dir("generated/sources/bufgen"))
164+
}
165+
}
176166
test {
177167
java {
178168
srcDir(layout.buildDirectory.dir("generated/test-sources/bufgen"))
@@ -183,7 +173,7 @@ sourceSets {
183173
apply(plugin = "com.diffplug.spotless")
184174
configure<SpotlessExtension> {
185175
java {
186-
targetExclude("src/main/java/build/buf/validate/**/*.java", "build/generated/test-sources/bufgen/**/*.java")
176+
targetExclude("build/generated/sources/bufgen/build/buf/validate/**/*.java", "build/generated/test-sources/bufgen/**/*.java")
187177
}
188178
kotlinGradle {
189179
ktlint()

conformance/buf.gen.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
version: v2
2+
clean: true
23
managed:
34
enabled: true
45
override:
56
- file_option: java_package_prefix
67
value: build
78
plugins:
89
- remote: buf.build/protocolbuffers/java:v30.2
9-
out: src/main/java
10+
out: build/generated/sources/bufgen

conformance/build.gradle.kts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ plugins {
77
application
88
java
99
alias(libs.plugins.errorprone)
10+
alias(libs.plugins.osdetector)
11+
}
12+
13+
val buf: Configuration by configurations.creating
14+
15+
tasks.register("configureBuf") {
16+
description = "Installs the Buf CLI."
17+
File(buf.asPath).setExecutable(true)
1018
}
1119

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

50+
tasks.register<Exec>("generateConformance") {
51+
dependsOn("configureBuf")
52+
description = "Generates sources for the bufbuild/protovalidate-testing module to build/generated/sources/bufgen."
53+
commandLine(
54+
buf.asPath,
55+
"generate",
56+
"--template",
57+
"buf.gen.yaml",
58+
"buf.build/bufbuild/protovalidate-testing:${project.findProperty("protovalidate.version")}",
59+
)
60+
}
61+
62+
sourceSets {
63+
main {
64+
java {
65+
srcDir(layout.buildDirectory.dir("generated/sources/bufgen"))
66+
}
67+
}
68+
}
69+
4270
tasks.withType<JavaCompile> {
71+
dependsOn("generateConformance")
4372
if (JavaVersion.current().isJava9Compatible) {
4473
doFirst {
4574
options.compilerArgs = mutableListOf("--release", "8")
4675
}
4776
}
4877
// Disable errorprone on generated code
49-
options.errorprone.excludedPaths.set(".*/src/main/java/build/buf/validate/conformance/.*")
78+
options.errorprone.excludedPaths.set(".*/build/generated/sources/bufgen/.*")
5079
}
5180

5281
// Disable javadoc for conformance tests
@@ -81,7 +110,7 @@ tasks {
81110
apply(plugin = "com.diffplug.spotless")
82111
configure<SpotlessExtension> {
83112
java {
84-
targetExclude("src/main/java/build/buf/validate/**/*.java")
113+
targetExclude("build/generated/sources/bufgen/**/*.java")
85114
}
86115
}
87116

@@ -92,6 +121,9 @@ dependencies {
92121

93122
implementation(libs.assertj)
94123
implementation(platform(libs.junit.bom))
124+
125+
buf("build.buf:buf:${libs.versions.buf.get()}:${osdetector.classifier}@exe")
126+
95127
testImplementation("org.junit.jupiter:junit-jupiter")
96128
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
97129

conformance/src/main/java/build/buf/validate/conformance/cases/AnEnum.java

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)