diff options
Diffstat (limited to 'tunnel/build.gradle.kts')
-rw-r--r-- | tunnel/build.gradle.kts | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/tunnel/build.gradle.kts b/tunnel/build.gradle.kts index fff3857d..44a10696 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,11 +8,12 @@ val pkg: String = providers.gradleProperty("wireguardPackageName").get() plugins { alias(libs.plugins.android.library) `maven-publish` + alias(libs.plugins.google.protobuf) signing } android { - compileSdk = 33 + compileSdk = 34 compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 @@ -65,12 +67,69 @@ android { } dependencies { + implementation(project(":bgp-java")) 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") { |