From 1eb6f59167bb82409d80c4825c8b017cd1430898 Mon Sep 17 00:00:00 2001 From: Kr328 <39107975+Kr328@users.noreply.github.com> Date: Sat, 11 Jan 2020 21:25:22 +0800 Subject: [PATCH] trim gopath for output --- buildSrc/src/main/java/GolangBindTask.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/GolangBindTask.kt b/buildSrc/src/main/java/GolangBindTask.kt index 3452a02..59d92c1 100644 --- a/buildSrc/src/main/java/GolangBindTask.kt +++ b/buildSrc/src/main/java/GolangBindTask.kt @@ -90,7 +90,7 @@ open class GolangBindTask : DefaultTask() { "go get golang.org/x/mobile/cmd/gomobile".exec() FileWriter(goBindPath.resolve("go.mod")).use { - it.write(appendReplace(sourcePath)) + it.write(buildStubGoModule(sourcePath)) } FileWriter(goBindPath.resolve("main.go")).use { it.write(STUB_GO_FILE_CONTENT) @@ -102,7 +102,7 @@ open class GolangBindTask : DefaultTask() { .copyRecursively(goPath.resolve("src"), overwrite = true) "gomobile init".exec(goBuildPath) - "gomobile bind -target=android github.com/kr328/cfa/bridge".exec(goBuildPath) + "gomobile bind -target=android \"-gcflags=all=-trimpath=$goPath\" github.com/kr328/cfa/bridge".exec(goBuildPath) nativeOutput.deleteRecursively() javaOutput.deleteRecursively() @@ -152,7 +152,7 @@ open class GolangBindTask : DefaultTask() { ?: throw GradleException("Android SDK not found.") } - private fun appendReplace(source: File): String { + private fun buildStubGoModule(source: File): String { val replaces = source.walk() .filter { it.name == "go.mod" } .flatMap { file ->