Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put back old common protos #357

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions benchmarks/schema/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@
plugins {
id("protokt.benchmarks-conventions")
}

spotless {
format("protobufLicense") {
targetExclude("src/main/resources/schema/benchmarks.proto")
}
}
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@

plugins {
id("protokt.common-conventions")
id("protokt.spotless-conventions")
}

spotless {
kotlin {
target("shared-src/**/*.kt")
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Toast, Inc.
* Copyright (c) 2025 Toast, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,13 +13,17 @@
* limitations under the License.
*/

spotless {
kotlin {
targetExclude(
"protokt-extensions/src/jvmMain/kotlin/com/toasttab/protokt/ext/inet_socket_address.kt",
"protokt-extensions/src/jvmMain/kotlin/com/toasttab/protokt/ext/protokt.kt",
"protokt-extensions-lite/src/jvmMain/kotlin/com/toasttab/protokt/ext/inet_socket_address.kt",
"protokt-extensions-lite/src/jvmMain/kotlin/com/toasttab/protokt/ext/protokt.kt"
)
import com.diffplug.gradle.spotless.SpotlessExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

fun Project.excludeLegacyProtoktFromSpotless(targetPattern: String) {
configure<SpotlessExtension> {
kotlin {
targetExclude(targetPattern)
}
format("kotlinLicense") {
targetExclude(targetPattern)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
* limitations under the License.
*/

plugins { idea }
plugins {
idea
id("protokt.spotless-conventions")
}

repositories {
mavenCentral()
}

version = rootProject.version
group = "com.toasttab.protokt"
123 changes: 46 additions & 77 deletions buildSrc/src/main/kotlin/protokt.spotless-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,88 +13,57 @@
* limitations under the License.
*/

import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.BaseKotlinExtension
import com.diffplug.gradle.spotless.FormatExtension

allprojects {
apply(plugin = "com.diffplug.spotless")
repositories { mavenCentral() }
plugins {
id("com.diffplug.spotless")
}

spotless {
val editorConfigOverride =
mapOf(
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
"ktlint_function_signature_body_expression_wrapping" to "always",
"ij_kotlin_packages_to_use_import_on_demand" to null,
)

fun BaseKotlinExtension.ktlintConfig() =
ktlint(libs.versions.ktlint.get()).editorConfigOverride(editorConfigOverride)

configure<SpotlessExtension> {
val editorConfigOverride =
mapOf(
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
"ktlint_function_signature_body_expression_wrapping" to "always",
"ij_kotlin_packages_to_use_import_on_demand" to null,
)
fun FormatExtension.kotlinTargets() =
target("src/**/*.kt", "buildSrc/src/**/*.kt")

kotlin {
ktlint(libs.versions.ktlint.get()).editorConfigOverride(editorConfigOverride)
target("**/*.kt")
targetExclude(
"buildSrc/build/generated-sources/**",
"**/generated/**",
"protokt-core-lite/src/jvmMain/kotlin/com/toasttab/protokt/**/*.kt",
"extensions/protokt-jvm-extensions-lite/src/main/kotlin/com/toasttab/protokt/ext/**.kt",
"extensions/protokt-extensions-lite/src/jvmMain/kotlin/com/toasttab/protokt/ext/**.kt",
"extensions/protokt-extensions/src/jvmMain/kotlin/com/toasttab/protokt/ext/**.kt",
"protokt-core/src/jvmMain/kotlin/com/toasttab/protokt/**/*.kt"
)
}
kotlin {
ktlintConfig()
kotlinTargets()
}

kotlinGradle {
ktlint(libs.versions.ktlint.get()).editorConfigOverride(editorConfigOverride)
target("**/*.kts")
targetExclude("buildSrc/build/**")
licenseHeaderFile(
rootProject.file("gradle/license-header-c-style"),
"(package |@file|import |fun )|buildscript |plugins |subprojects |spotless |group ="
)
}
kotlinGradle {
ktlintConfig()
target("*.kts", "buildSrc/**/*.kts")
targetExclude("**/kotlin-dsl/plugins-blocks/extracted/**")
licenseHeaderFile(
rootProject.file("gradle/license-header-c-style"),
"(package |@file|import |fun )|buildscript |plugins |group ="
)
}

format("kotlinLicense") {
target("**/*.kt")
licenseHeaderFile(
rootProject.file("gradle/license-header-c-style"),
"(package |@file|import |fun )"
)
targetExclude(
"**/buildSrc/build/generated/**",
"**/build/generated-sources/kotlin-dsl-*/**",
"**/build/generated/source/**",
"**/protokt/v1/animals/**",
"**/protokt/v1/helloworld/**",
"**/protokt/v1/io/grpc/examples/**"
)
}
// Separate from ktlint to allow license formatting for files with shared copyrights to be specified independently
format("kotlinLicense") {
kotlinTargets()
licenseHeaderFile(
rootProject.file("gradle/license-header-c-style"),
"(package |@file|import |fun )"
)
}

format("protobufLicense") {
target("**/*.proto")
targetExclude(
listOf(
"benchmarks/schema/src/main/resources/schema/benchmarks.proto",
"examples/protos/src/main/proto/animals/dog.proto",
"examples/protos/src/main/proto/animals/pig.proto",
"examples/protos/src/main/proto/animals/sheep.proto",
"examples/protos/src/main/proto/helloworld/hello_world.proto",
"examples/protos/src/main/proto/io/grpc/examples/route_guide.proto",
"testing/conformance/driver/src/main/proto/conformance/conformance.proto",
"testing/conformance/driver/src/main/proto/protobuf_test_messages/editions/proto3/test_messages_proto3_editions.proto",
"testing/conformance/driver/src/main/proto/protobuf_test_messages/editions/test_messages_edition2023.proto",
"testing/conformance/driver/src/main/proto/protobuf_test_messages/proto3/test_messages_proto3.proto",
"testing/interop/src/main/proto/tutorial/addressbook.proto",
"testing/interop/src/main/proto/google/protobuf/unittest_import.proto",
"testing/interop/src/main/proto/google/protobuf/unittest_import_public.proto",
"testing/interop/src/main/proto/google/protobuf/unittest_proto3.proto",
).map(rootProject::file) +
"node_modules/**" +
"**/build/extracted-include-protos/**" +
"**/build/resources/**"
)
licenseHeaderFile(
rootProject.file("gradle/license-header-c-style"),
"(syntax |edition )"
)
}
format("protobufLicense") {
target("src/**/*.proto")
licenseHeaderFile(
rootProject.file("gradle/license-header-c-style"),
"(syntax |edition )"
)
}
}
6 changes: 6 additions & 0 deletions examples/grpc-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ plugins {
localProtokt()
pureKotlin()

spotless {
format("kotlinLicense") {
targetExclude("src/main/kotlin/protokt/v1/io/grpc/examples/routeguide/**.kt")
}
}

protokt {
generate {
grpcDescriptors = true
Expand Down
10 changes: 10 additions & 0 deletions examples/grpc-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ plugins {
localProtokt()
pureKotlin()

spotless {
format("kotlinLicense") {
targetExclude(
"src/**/kotlin/protokt/v1/animals/**.kt",
"src/**/kotlin/protokt/v1/helloworld/**.kt",
"src/**/kotlin/protokt/v1/io/grpc/examples/routeguide/**.kt"
)
}
}

protokt {
generate {
types = false
Expand Down
9 changes: 9 additions & 0 deletions examples/grpc-node/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ import protokt.v1.gradle.protokt

plugins {
`kotlin-multiplatform`
id("protokt.common-conventions")
}

spotless {
format("kotlinLicense") {
targetExclude(
"src/**/kotlin/protokt/v1/io/grpc/examples/routeguide/**.kt"
)
}
}

kotlin {
Expand Down
9 changes: 9 additions & 0 deletions examples/protos/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ plugins {
id("org.jetbrains.kotlin.plugin.serialization") version libs.versions.kotlin
}

spotless {
format("kotlinLicense") {
targetExclude("src/commonMain/kotlin/protokt/v1/io/grpc/examples/routeguide/Points.kt")
}
format("protobufLicense") {
targetExclude("src/main/proto/**/*.proto")
}
}

localProtokt()

protokt {
Expand Down
10 changes: 1 addition & 9 deletions extensions/protokt-extensions-lite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@ plugins {
}

localProtokt()

spotless {
kotlin {
targetExclude(
"src/jvmMain/kotlin/com/toasttab/protokt/ext/inet_socket_address.kt",
"src/jvmMain/kotlin/com/toasttab/protokt/ext/protokt.kt"
)
}
}
excludeLegacyProtoktFromSpotless("src/jvmMain/kotlin/com/toasttab/protokt/ext/**.kt")

protokt {
generate {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright (c) 2023 Toast, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

// Generated by protokt version 0.12.1. Do not modify.
Expand Down
10 changes: 1 addition & 9 deletions extensions/protokt-extensions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins {

localProtokt()
compatibleWithAndroid()
excludeLegacyProtoktFromSpotless("src/jvmMain/kotlin/com/toasttab/protokt/ext/**/*.kt")

configure<ExpediterExtension> {
ignore {
Expand All @@ -32,15 +33,6 @@ configure<ExpediterExtension> {
}
}

spotless {
kotlin {
targetExclude(
"src/jvmMain/kotlin/com/toasttab/protokt/ext/inet_socket_address.kt",
"src/jvmMain/kotlin/com/toasttab/protokt/ext/protokt.kt"
)
}
}

protokt {
generate {
types = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
* Copyright (c) 2023 Toast, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

@file:Suppress("DEPRECATION")

// Generated by protokt version 0.12.1. Do not modify.
Expand Down
Loading