Skip to content

Commit

Permalink
Improve code generation in connect-kotlin (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkwarren authored Sep 1, 2023
1 parent 70bf6a9 commit d1cc0f8
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 2,033 deletions.
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
!/**/src/**/build/*
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
/examples/generated-google-java/src/main/
/examples/generated-google-javalite/src/main/
/crosstests/google-java/src/main/kotlin/generated/
/crosstests/google-java/src/main/java/generated/
/crosstests/google-javalite/src/main/kotlin/generated/
/crosstests/google-javalite/src/main/java/generated/
/local.properties
/protoc-gen-connect-kotlin/src/test/java/
/.gradle
/.idea
/.tmp
Expand Down
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,12 @@ buildplugin: ## Build the connect-kotlin protoc plugin.
.PHONY: clean
clean: ## Cleans the underlying build.
./gradlew $(GRADLE_ARGS) clean
rm -rf examples/generated-google-java/src/main
rm -rf examples/generated-google-javalite/src/main

rm -rf crosstests/google-java/src/main/java/generated
rm -rf crosstests/google-java/src/main/kotlin/generated
rm -rf crosstests/google-javalite/src/main/java/generated
rm -rf crosstests/google-javalite/src/main/kotlin/generated

rm -rf protoc-gen-connect-kotlin/src/test/java/

.PHONY: crosstestsrun
crosstestsrun: crosstestsrunjava ## Run the cross tests.

.PHONY: crosstestsrunjava
crosstestsrunjava: ## Run the cross tests for protoc-gen-java integration.
crosstestsrunjava: generate ## Run the cross tests for protoc-gen-java integration.
./gradlew $(GRADLE_ARGS) crosstest:google-java:test

ifeq ($(UNAME_OS),Darwin)
Expand Down
12 changes: 6 additions & 6 deletions crosstests/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ managed:
plugins:
# Java crosstests.
- plugin: connect-kotlin
out: google-java/src/main/kotlin/generated
out: google-java/build/generated/sources/bufgen
path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin
opt:
- generateCallbackMethods=true
- generateCoroutineMethods=true
- generateBlockingUnaryMethods=true
- plugin: java
out: google-java/src/main/java/generated
out: google-java/build/generated/sources/bufgen
protoc_path: .tmp/bin/protoc
- plugin: kotlin
out: google-java/src/main/kotlin/generated
out: google-java/build/generated/sources/bufgen
protoc_path: .tmp/bin/protoc
# Javalite crosstests.
- plugin: connect-kotlin
out: google-javalite/src/main/kotlin/generated
out: google-javalite/build/generated/sources/bufgen
path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin
- plugin: java
out: google-javalite/src/main/java/generated
out: google-javalite/build/generated/sources/bufgen
protoc_path: .tmp/bin/protoc
opt: lite
- plugin: kotlin
out: google-javalite/src/main/kotlin/generated
out: google-javalite/build/generated/sources/bufgen
protoc_path: .tmp/bin/protoc
opt: lite
9 changes: 5 additions & 4 deletions crosstests/google-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ tasks {
}

sourceSets {
java.sourceSets["main"].java {
srcDir("src/main/java/generated")
main {
java {
srcDir("build/generated/sources/bufgen")
}
}
}

dependencies {

implementation(libs.kotlin.coroutines.core)
implementation(libs.protobuf.kotlin)
implementation(project(":crosstests:common"))
Expand All @@ -38,6 +39,6 @@ dependencies {

configure<SpotlessExtension> {
kotlin {
targetExclude("**/generated/**/*.kt")
targetExclude("build/generated/sources/bufgen/**/*.kt")
}
}
44 changes: 44 additions & 0 deletions crosstests/google-javalite/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import com.diffplug.gradle.spotless.SpotlessExtension

plugins {
application
java
kotlin("jvm")
}

tasks {
compileKotlin {
kotlinOptions {
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
}
}

sourceSets {
main {
java {
srcDir("build/generated/sources/bufgen")
}
}
}

dependencies {
implementation(libs.kotlin.coroutines.core)
implementation(libs.protobuf.kotlin)
implementation(project(":crosstests:common"))
implementation(project(":extensions:google-java"))
implementation(project(":okhttp"))

testImplementation(libs.okhttp.core)
testImplementation(libs.junit)
testImplementation(libs.assertj)
testImplementation(libs.mockito)
testImplementation(libs.kotlin.coroutines.core)
testImplementation(libs.testcontainers)
}

configure<SpotlessExtension> {
kotlin {
targetExclude("build/generated/sources/bufgen/**/*.kt")
}
}
8 changes: 4 additions & 4 deletions examples/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ managed:
java_package_prefix: "build"
plugins:
- plugin: connect-kotlin
out: generated-google-java/src/main/kotlin
out: generated-google-java/build/generated/sources/bufgen
path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin
- plugin: java
out: generated-google-java/src/main/java
out: generated-google-java/build/generated/sources/bufgen
protoc_path: .tmp/bin/protoc
- plugin: connect-kotlin
out: generated-google-javalite/src/main/kotlin
out: generated-google-javalite/build/generated/sources/bufgen
path: ./protoc-gen-connect-kotlin/build/install/protoc-gen-connect-kotlin/bin/protoc-gen-connect-kotlin
- plugin: java
out: generated-google-javalite/src/main/java
out: generated-google-javalite/build/generated/sources/bufgen
protoc_path: .tmp/bin/protoc
opt: lite
6 changes: 4 additions & 2 deletions examples/generated-google-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ tasks {
}

sourceSets {
java.sourceSets["main"].java {
srcDir("src/main/java/")
main {
java {
srcDir("build/generated/sources/bufgen")
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions examples/generated-google-javalite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ tasks {
}

sourceSets {
java.sourceSets["main"].java {
srcDir("src/main/java/")
main {
java {
srcDir("build/generated/sources/bufgen")
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion extensions/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ types:
- google.rpc.Status
plugins:
- plugin: java
out: google-java/src/main/java
out: google-java/build/generated/sources/bufgen
protoc_path: .tmp/bin/protoc
- plugin: java
out: google-javalite/build/generated/sources/bufgen
protoc_path: .tmp/bin/protoc
opt: lite
6 changes: 4 additions & 2 deletions extensions/google-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ plugins {
}

sourceSets {
java.sourceSets["main"].java {
srcDir("src/main/java/generated")
main {
java {
srcDir("build/generated/sources/bufgen")
}
}
}

Expand Down
Loading

0 comments on commit d1cc0f8

Please sign in to comment.