-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat-ip-prefix
- Loading branch information
Showing
80 changed files
with
16,419 additions
and
14,892 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ jobs: | |
java-version: '17' | ||
cache: 'gradle' | ||
- name: Test conformance | ||
run: make conformance | ||
run: make conformance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import com.vanniktech.maven.publish.JavaLibrary | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
import com.diffplug.gradle.spotless.SpotlessExtension | ||
import com.vanniktech.maven.publish.JavaLibrary | ||
import com.vanniktech.maven.publish.JavadocJar | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
import net.ltgt.gradle.errorprone.CheckSeverity | ||
import net.ltgt.gradle.errorprone.errorprone | ||
|
||
plugins { | ||
`version-catalog` | ||
|
||
`java-library` | ||
alias(libs.plugins.errorprone) | ||
alias(libs.plugins.git) | ||
alias(libs.plugins.maven) | ||
} | ||
|
||
|
@@ -18,12 +17,133 @@ java { | |
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
// The releaseVersion property is set on official releases in the release.yml workflow. | ||
// If not specified, we attempt to calculate a snapshot version based on the last tagged release. | ||
// So if the local build's last tag was v0.1.9, this will set snapshotVersion to 0.1.10-SNAPSHOT. | ||
// If this fails for any reason, we'll fall back to using 0.0.0-SNAPSHOT version. | ||
val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra | ||
val details = versionDetails() | ||
var snapshotVersion = "0.0.0-SNAPSHOT" | ||
val matchResult = """^v(\d+)\.(\d+)\.(\d+)$""".toRegex().matchEntire(details.lastTag) | ||
if (matchResult != null) { | ||
val (major, minor, patch) = matchResult.destructured | ||
snapshotVersion = "$major.$minor.${patch.toInt() + 1}-SNAPSHOT" | ||
} | ||
val releaseVersion = project.findProperty("releaseVersion") as String? ?: snapshotVersion | ||
|
||
val bufCLIFile = project.layout.buildDirectory.file("gobin/buf").get().asFile | ||
val bufCLIPath: String = bufCLIFile.absolutePath | ||
val bufLicenseHeaderCLIFile = project.layout.buildDirectory.file("gobin/license-header").get().asFile | ||
val bufLicenseHeaderCLIPath: String = bufLicenseHeaderCLIFile.absolutePath | ||
|
||
tasks.register<Exec>("installBuf") { | ||
description = "Installs the Buf CLI." | ||
environment("GOBIN", bufCLIFile.parentFile.absolutePath) | ||
outputs.file(bufCLIFile) | ||
commandLine("go", "install", "github.com/bufbuild/buf/cmd/buf@latest") | ||
} | ||
|
||
tasks.register<Exec>("installLicenseHeader") { | ||
description = "Installs the Buf license-header CLI." | ||
environment("GOBIN", bufLicenseHeaderCLIFile.parentFile.absolutePath) | ||
outputs.file(bufLicenseHeaderCLIFile) | ||
commandLine("go", "install", "github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@latest") | ||
} | ||
|
||
tasks.register<Exec>("licenseHeader") { | ||
dependsOn("installLicenseHeader") | ||
description = "Runs the Buf license-header CLI." | ||
commandLine( | ||
bufLicenseHeaderCLIPath, | ||
"--license-type", | ||
"apache", | ||
"--copyright-holder", | ||
"Buf Technologies, Inc.", | ||
"--year-range", | ||
project.findProperty("license-header.years")!!.toString(), | ||
"--ignore", | ||
"src/main/java/build/buf/validate/", | ||
"--ignore", | ||
"conformance/src/main/java/build/buf/validate/conformance/", | ||
) | ||
} | ||
|
||
tasks.register<Exec>("generateTestSourcesImports") { | ||
dependsOn("installBuf") | ||
description = "Generates code with buf generate --include-imports for unit tests." | ||
commandLine( | ||
bufCLIPath, | ||
"generate", | ||
"--template", | ||
"src/test/resources/proto/buf.gen.imports.yaml", | ||
"src/test/resources/proto", | ||
"--include-imports", | ||
) | ||
} | ||
|
||
tasks.register<Exec>("generateTestSourcesNoImports") { | ||
dependsOn("installBuf") | ||
description = "Generates code with buf generate --include-imports for unit tests." | ||
commandLine(bufCLIPath, "generate", "--template", "src/test/resources/proto/buf.gen.noimports.yaml", "src/test/resources/proto") | ||
} | ||
|
||
tasks.register("generateTestSources") { | ||
dependsOn("generateTestSourcesImports", "generateTestSourcesNoImports") | ||
description = "Generates code with buf generate for unit tests" | ||
} | ||
|
||
tasks.register<Exec>("exportProtovalidateModule") { | ||
dependsOn("installBuf") | ||
description = "Exports the bufbuild/protovalidate module sources to src/main/resources." | ||
commandLine( | ||
bufCLIPath, | ||
"export", | ||
"buf.build/bufbuild/protovalidate:${project.findProperty("protovalidate.version")}", | ||
"--output", | ||
"src/main/resources", | ||
) | ||
} | ||
|
||
tasks.register<Exec>("generateSources") { | ||
dependsOn("installBuf") | ||
description = "Generates sources for the bufbuild/protovalidate module sources to src/main/java." | ||
commandLine(bufCLIPath, "generate", "--template", "buf.gen.yaml", "src/main/resources") | ||
} | ||
|
||
tasks.register<Exec>("generateConformance") { | ||
dependsOn("installBuf") | ||
description = "Generates sources for the bufbuild/protovalidate-testing module to conformance/src/main/java." | ||
commandLine( | ||
bufCLIPath, | ||
"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", | ||
"exportProtovalidateModule", | ||
"generateSources", | ||
"generateConformance", | ||
"licenseHeader", | ||
) | ||
} | ||
|
||
tasks.withType<JavaCompile> { | ||
if (JavaVersion.current().isJava9Compatible) doFirst { | ||
options.compilerArgs = mutableListOf("--release", "8") | ||
dependsOn("generateTestSources") | ||
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/.*") | ||
options.errorprone.excludedPaths.set("(.*/src/main/java/build/buf/validate/.*|.*/build/generated/.*)") | ||
if (!name.lowercase().contains("test")) { | ||
options.errorprone { | ||
check("NullAway", CheckSeverity.ERROR) | ||
|
@@ -49,14 +169,27 @@ buildscript { | |
} | ||
} | ||
|
||
sourceSets { | ||
test { | ||
java { | ||
srcDir(layout.buildDirectory.dir("generated/test-sources/bufgen")) | ||
} | ||
} | ||
} | ||
|
||
apply(plugin = "com.diffplug.spotless") | ||
configure<SpotlessExtension> { | ||
java { | ||
targetExclude("src/main/java/build/buf/validate/**/*.java") | ||
targetExclude("src/main/java/build/buf/validate/**/*.java", "build/generated/test-sources/bufgen/**/*.java") | ||
} | ||
kotlinGradle { | ||
ktlint() | ||
target("**/*.kts") | ||
} | ||
} | ||
|
||
allprojects { | ||
version = releaseVersion | ||
repositories { | ||
mavenCentral() | ||
maven { | ||
|
@@ -75,6 +208,13 @@ allprojects { | |
trimTrailingWhitespace() | ||
} | ||
} | ||
tasks.withType<Jar>().configureEach { | ||
if (name == "jar") { | ||
manifest { | ||
attributes("Implementation-Version" to releaseVersion) | ||
} | ||
} | ||
} | ||
} | ||
|
||
mavenPublishing { | ||
|
@@ -83,31 +223,28 @@ mavenPublishing { | |
if (isAutoReleased) { | ||
signAllPublications() | ||
} | ||
val releaseVersion = project.findProperty("releaseVersion") as String? ?: System.getenv("VERSION") | ||
coordinates("build.buf", "protovalidate", releaseVersion ?: "0.0.0-SNAPSHOT") | ||
coordinates("build.buf", "protovalidate", releaseVersion) | ||
pomFromGradleProperties() | ||
configure(JavaLibrary( | ||
configure( | ||
JavaLibrary( | ||
// configures the -javadoc artifact, possible values: | ||
// - `JavadocJar.None()` don't publish this artifact | ||
// - `JavadocJar.Empty()` publish an emprt jar | ||
// - `JavadocJar.Empty()` publish an empty jar | ||
// - `JavadocJar.Javadoc()` to publish standard javadocs | ||
javadocJar = JavadocJar.Javadoc(), | ||
// whether to publish a sources jar | ||
sourcesJar = true, | ||
) | ||
), | ||
) | ||
pom { | ||
name.set("connect-library") // This is overwritten in subprojects. | ||
name.set("protovalidate-java") | ||
group = "build.buf" | ||
val releaseVersion = project.findProperty("releaseVersion") as String? | ||
// Default to snapshot versioning for local publishing. | ||
version = releaseVersion ?: "0.0.0-SNAPSHOT" | ||
description.set("Protocol Buffer Validation") | ||
url.set("https://github.com/bufbuild/protovalidate-java") | ||
licenses { | ||
license { | ||
name.set("The Apache Software License, Version 2.0") | ||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") | ||
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") | ||
distribution.set("repo") | ||
} | ||
} | ||
|
@@ -123,7 +260,6 @@ mavenPublishing { | |
developerConnection.set("scm:git:ssh://[email protected]/bufbuild/protovalidate-java.git") | ||
} | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
|
Oops, something went wrong.