Skip to content

Commit

Permalink
Build GrpcTestApps without polluting grpc-client
Browse files Browse the repository at this point in the history
Tmp
  • Loading branch information
wba2hi committed Nov 12, 2024
1 parent f829f7d commit 651736d
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 12 deletions.
38 changes: 38 additions & 0 deletions GrpcClientTestApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,41 @@ dependencies {
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}

tasks.register<Delete>("cleanProtos") {
delete(
fileTree("$rootDir/grpc-client/src/main") {
exclude("java")
include(
"*/Door.proto",
"*/FoldingService.proto",
"*/FronthousingService.proto",
"*/VehicleService.json",
)
},
)
}

tasks.register("setup") {
finalizedBy(":grpc-client:generateGrpcServiceClients", ":grpc-client:assemble")

doFirst {
copy {
from("$rootDir/test/proto")
into("$rootDir/grpc-client/src/main/proto")
}
copy {
from("$rootDir/test/resources")
into("$rootDir/grpc-client/src/main/resources")
}
}
}

afterEvaluate {
tasks.getByName("clean").finalizedBy("cleanProtos")

tasks.getByName("test").dependsOn("setup")
tasks.getByName("test").finalizedBy("cleanProtos")
tasks.getByName("assemble").dependsOn("setup")
tasks.getByName("assemble").finalizedBy("cleanProtos")
}
38 changes: 38 additions & 0 deletions GrpcServerTestApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,41 @@ dependencies {
implementation(project(":sdk"))
implementation(project(":grpc-client"))
}

tasks.register<Delete>("cleanProtos") {
delete(
fileTree("$rootDir/grpc-client/src/main") {
exclude("java")
include(
"*/Door.proto",
"*/FoldingService.proto",
"*/FronthousingService.proto",
"*/VehicleService.json",
)
},
)
}

tasks.register("setup") {
finalizedBy(":grpc-client:generateGrpcServiceClients", ":grpc-client:assemble")

doFirst {
copy {
from("$rootDir/test/proto")
into("$rootDir/grpc-client/src/main/proto")
}
copy {
from("$rootDir/test/resources")
into("$rootDir/grpc-client/src/main/resources")
}
}
}

afterEvaluate {
tasks.getByName("clean").finalizedBy("cleanProtos")

tasks.getByName("test").dependsOn("setup")
tasks.getByName("test").finalizedBy("cleanProtos")
tasks.getByName("assemble").dependsOn("setup")
tasks.getByName("assemble").finalizedBy("cleanProtos")
}
26 changes: 14 additions & 12 deletions grpc-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,22 @@ tasks.register<Exec>("installDependencies") {
commandLine("python3", "-m", "pip", "install", "-r", "./requirements.txt")
}

fileTree("$projectDir/src/main/resources").forEach { file ->
val name = file.nameWithoutExtension
tasks.register<Exec>("generateGrpcServiceClientFor$name") {
group = "grpc"
dependsOn("installDependencies", "generateProto")

workingDir("$projectDir/tools")
val inputFile = file.path
commandLine("python3", "generate_code.py", inputFile)
tasks.register("generateGrpcServiceClients") {
dependsOn("installDependencies", "generateProto")

doLast {
fileTree("$projectDir/src/main/resources").forEach { file ->
exec {
workingDir("$projectDir/tools")
val inputFilePath = file.path
commandLine("python3", "generate_code.py", inputFilePath)
}
}
}
}

tasks.getByName("compileJava") {
dependsOn("generateGrpcServiceClientFor$name")
}
tasks.getByName("compileJava") {
dependsOn("generateGrpcServiceClients")
}

tasks.register<Jar>("javadocJar") {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 651736d

Please sign in to comment.