Fix: should add main golang source as input

This commit is contained in:
kr328 2021-09-12 00:43:32 +08:00
parent c0e1e45b72
commit 07ff81f4db

View File

@ -1,3 +1,4 @@
import com.github.kr328.golang.GolangBuildTask
import com.github.kr328.golang.GolangPlugin import com.github.kr328.golang.GolangPlugin
import java.io.FileOutputStream import java.io.FileOutputStream
import java.net.URL import java.net.URL
@ -14,6 +15,7 @@ val geoipDatabaseUrl =
"https://github.com/Dreamacro/maxmind-geoip/releases/latest/download/Country.mmdb" "https://github.com/Dreamacro/maxmind-geoip/releases/latest/download/Country.mmdb"
val geoipInvalidate = Duration.ofDays(7)!! val geoipInvalidate = Duration.ofDays(7)!!
val geoipOutput = buildDir.resolve("intermediates/golang_blob") val geoipOutput = buildDir.resolve("intermediates/golang_blob")
val golangSource = file("src/main/golang/native")
golang { golang {
sourceSets { sourceSets {
@ -37,7 +39,7 @@ android {
all { all {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
arguments("-DGO_SOURCE:STRING=${file("src/main/golang/native")}") arguments("-DGO_SOURCE:STRING=${golangSource}")
arguments("-DGO_OUTPUT:STRING=${GolangPlugin.outputDirOf(project, null, null)}") arguments("-DGO_OUTPUT:STRING=${GolangPlugin.outputDirOf(project, null, null)}")
arguments("-DFLAVOR_NAME:STRING=$name") arguments("-DFLAVOR_NAME:STRING=$name")
} }
@ -65,6 +67,12 @@ repositories {
mavenCentral() mavenCentral()
} }
afterEvaluate {
tasks.withType(GolangBuildTask::class.java).forEach {
it.inputs.file(golangSource)
}
}
task("downloadGeoipDatabase") { task("downloadGeoipDatabase") {
val databaseFile = geoipOutput.resolve("Country.mmdb") val databaseFile = geoipOutput.resolve("Country.mmdb")
val moduleFile = geoipOutput.resolve("go.mod") val moduleFile = geoipOutput.resolve("go.mod")