@@ -11,10 +11,6 @@ plugins {
1111 id(" golang-android" )
1212}
1313
14- val geoipDatabaseUrl =
15- " https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
16- val geoipInvalidate = Duration .ofDays(7 )!!
17- val geoipOutput = buildDir.resolve(" intermediates/golang_blob" )
1814val golangSource = file(" src/main/golang/native" )
1915
2016golang {
@@ -66,52 +62,4 @@ afterEvaluate {
6662 tasks.withType(GolangBuildTask ::class .java).forEach {
6763 it.inputs.dir(golangSource)
6864 }
69- }
70-
71- task(" downloadGeoipDatabase" ) {
72- val databaseFile = geoipOutput.resolve(" Country.mmdb" )
73- val moduleFile = geoipOutput.resolve(" go.mod" )
74- val sourceFile = geoipOutput.resolve(" blob.go" )
75-
76- val moduleContent = """
77- module "cfa/blob"
78- """ .trimIndent()
79-
80- val sourceContent = """
81- package blob
82-
83- import _ "embed"
84-
85- //go:embed Country.mmdb
86- var GeoipDatabase []byte
87- """ .trimIndent()
88-
89- outputs.dir(geoipOutput)
90-
91- onlyIf {
92- System .currentTimeMillis() - databaseFile.lastModified() > geoipInvalidate.toMillis()
93- }
94-
95- doLast {
96- geoipOutput.mkdirs()
97-
98- moduleFile.writeText(moduleContent)
99- sourceFile.writeText(sourceContent)
100-
101- URL (geoipDatabaseUrl).openConnection().getInputStream().use { input ->
102- FileOutputStream (databaseFile).use { output ->
103- input.copyTo(output)
104- }
105- }
106- }
107- }
108-
109- afterEvaluate {
110- val downloadTask = tasks[" downloadGeoipDatabase" ]
111-
112- tasks.forEach {
113- if (it.name.startsWith(" externalGolangBuild" )) {
114- it.dependsOn(downloadTask)
115- }
116- }
117- }
65+ }
0 commit comments