summaryrefslogtreecommitdiffhomepage
path: root/tunnel/build.gradle.kts
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2021-11-20 20:03:12 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2023-10-26 00:11:06 +0200
commit717305cf77e90a852a2945ecc5dae9d114f3deb6 (patch)
treecf65c4167ca64d1bb7889c8d61d317e2c858142b /tunnel/build.gradle.kts
parentfefb547341388d1359e948a7acdea259c3a0953b (diff)
tunnel: add gRPC over unix domain socket to the go backend
With gRPC it will be easier to extend the go backend API. In this commit the Version function is reimplemented in gRPC. Gitignore generated protobuf files.
Diffstat (limited to 'tunnel/build.gradle.kts')
-rw-r--r--tunnel/build.gradle.kts58
1 files changed, 58 insertions, 0 deletions
diff --git a/tunnel/build.gradle.kts b/tunnel/build.gradle.kts
index 589d72da..6793c3ce 100644
--- a/tunnel/build.gradle.kts
+++ b/tunnel/build.gradle.kts
@@ -1,5 +1,6 @@
@file:Suppress("UnstableApiUsage")
+import com.google.protobuf.gradle.*
import org.gradle.api.tasks.testing.logging.TestLogEvent
val pkg: String = providers.gradleProperty("wireguardPackageName").get()
@@ -7,6 +8,7 @@ val pkg: String = providers.gradleProperty("wireguardPackageName").get()
plugins {
alias(libs.plugins.android.library)
`maven-publish`
+ alias(libs.plugins.google.protobuf)
signing
}
@@ -67,10 +69,66 @@ android {
dependencies {
implementation(libs.androidx.annotation)
implementation(libs.androidx.collection)
+ implementation(libs.grpc.android)
+ implementation(libs.grpc.okhttp)
+ implementation(libs.grpc.protobuf.lite)
+ implementation(libs.grpc.stub)
+ compileOnly(libs.javax.annotation.api)
compileOnly(libs.jsr305)
testImplementation(libs.junit)
}
+protobuf {
+ protoc {
+ // The artifact spec for the Protobuf Compiler
+ artifact = "com.google.protobuf:protoc:${libs.versions.protoc.get()}"
+ }
+ plugins {
+ // Optional: an artifact spec for a protoc plugin, with "grpc" as
+ // the identifier, which can be referred to in the "plugins"
+ // container of the "generateProtoTasks" closure.
+ id("grpc") {
+ artifact = "io.grpc:protoc-gen-grpc-java:${libs.versions.protocgengrpc.get()}"
+ }
+ id("java") {
+ }
+ }
+ generateProtoTasks {
+ all().forEach { task ->
+ task.plugins{
+ id("grpc") {
+ option("lite")
+ }
+ id("java") {
+ option("lite")
+ }
+ }
+ }
+ }
+}
+
+afterEvaluate({ ->
+ // All custom configurations created by the protobuf plugin,
+ // are only available at this point.
+ var protoc = configurations.named("protobufToolsLocator_protoc")
+ var protocCache = "${gradle.gradleUserHomeDir}/caches/protoc-bin-${libs.versions.protoc.get()}"
+
+ tasks.register("copyProtoc", Copy::class) {
+ // Used by tunnel/tools/libwg-go/Makefile run in tools/CMakeLists.txt
+ from(protoc)
+ into(protocCache)
+ rename("protoc-.*", "protoc")
+ setFileMode(7 * 64 + 7 * 8 + 5) // 0775
+ }
+
+ tasks.named("preBuild").get().dependsOn("copyProtoc")
+
+ // Extract duration.proto used by external library in libwg.proto
+ tasks.named("preDebugBuild").get().dependsOn(tasks.named("extractIncludeDebugProto").get())
+ tasks.named("preReleaseBuild").get().dependsOn(tasks.named("extractIncludeReleaseProto").get())
+ println("done afterEvaluate")
+})
+
publishing {
publications {
register<MavenPublication>("release") {