fix docker for tauri android build

This commit is contained in:
lendry
2026-06-27 00:10:28 +03:00
parent 886b7e9ade
commit 1a30e7e21c
98 changed files with 24218 additions and 68 deletions

View File

@@ -1,36 +1,10 @@
import org.gradle.api.GradleException
plugins {
java
}
repositories {
google()
mavenCentral()
}
val agpVersion: String = providers.gradleProperty("agpVersion").orElse("8.11.0").get()
configurations {
create("agp")
create("androidDeps")
create("buildPlugins")
}
dependencies {
add("agp", "com.android.tools.build:gradle:$agpVersion")
add("buildPlugins", "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
add("buildPlugins", "org.jetbrains.kotlin:kotlin-stdlib:1.9.25")
add("androidDeps", "androidx.webkit:webkit:1.14.0")
add("androidDeps", "androidx.appcompat:appcompat:1.7.1")
add("androidDeps", "androidx.activity:activity-ktx:1.10.1")
add("androidDeps", "com.google.android.material:material:1.12.0")
add("androidDeps", "androidx.lifecycle:lifecycle-process:2.10.0")
add("androidDeps", "androidx.core:core-ktx:1.9.0")
add("androidDeps", "androidx.browser:browser:1.8.0")
add("androidDeps", "androidx.core:core:1.13.0")
allprojects {
repositories {
google()
mavenCentral()
}
}
fun installArtifact(
@@ -46,6 +20,28 @@ fun installArtifact(
src.copyTo(dir.resolve("$name-$version.$ext"), overwrite = true)
}
fun googleMavenBases(group: String): List<String> =
if (group.startsWith("com.android") || group.startsWith("androidx") || group.startsWith("com.google.android")) {
listOf(
"https://dl.google.com/dl/android/maven2",
"https://dl.google.com/android/maven2",
"https://maven.google.com",
)
} else {
listOf(
"https://repo.maven.apache.org/maven2",
"https://dl.google.com/dl/android/maven2",
"https://maven.google.com",
)
}
fun downloadUrl(url: String, dest: File) {
dest.parentFile.mkdirs()
exec {
commandLine("curl", "-fsSL", url, "-o", dest.absolutePath)
}
}
fun ensurePom(root: File, group: String, name: String, version: String) {
val dir = root.resolve("${group.replace('.', '/')}/$name/$version")
dir.mkdirs()
@@ -55,27 +51,10 @@ fun ensurePom(root: File, group: String, name: String, version: String) {
}
val groupPath = group.replace('.', '/')
val bases = when {
group.startsWith("com.android") || group.startsWith("androidx") || group.startsWith("com.google.android") ->
listOf(
"https://dl.google.com/dl/android/maven2",
"https://dl.google.com/android/maven2",
"https://maven.google.com",
)
else ->
listOf(
"https://repo.maven.apache.org/maven2",
"https://dl.google.com/dl/android/maven2",
"https://maven.google.com",
)
}
for (base in bases) {
for (base in googleMavenBases(group)) {
val url = "$base/$groupPath/$name/$version/$name-$version.pom"
try {
exec {
commandLine("curl", "-fsSL", url, "-o", pom.absolutePath)
}
downloadUrl(url, pom)
if (pom.exists() && pom.length() > 0L) {
return
}
@@ -87,8 +66,10 @@ fun ensurePom(root: File, group: String, name: String, version: String) {
throw GradleException("POM not found: $group:$name:$version")
}
fun exportConfiguration(configName: String, offlineRoot: File): Int {
val configuration = configurations.getByName(configName)
fun exportConfiguration(projectPath: String, configName: String, offlineRoot: File): Int {
val target = project(projectPath)
val configuration = target.configurations.getByName(configName)
configuration.resolve()
val modules = linkedSetOf<Triple<String, String, String>>()
configuration.resolvedConfiguration.resolvedArtifacts.forEach { artifact ->
@@ -108,15 +89,20 @@ fun exportConfiguration(configName: String, offlineRoot: File): Int {
ensurePom(offlineRoot, group, name, version)
}
println("Exported ${modules.size} modules from configuration ${configName}")
println("Exported ${modules.size} modules from ${projectPath}:${configName}")
return modules.size
}
fun exportAndroidRuntimeClasspath(offlineRoot: File): Int =
exportConfiguration(":app", "releaseRuntimeClasspath", offlineRoot)
val agpVersion: String = providers.gradleProperty("agpVersion").orElse("8.11.0").get()
tasks.register("exportOfflineMaven") {
dependsOn(configurations.named("agp"))
dependsOn(":tools:compileJava")
doLast {
val offlineRoot = file("${rootProject.projectDir}/../offline-maven").apply { mkdirs() }
val modules = exportConfiguration("agp", offlineRoot)
val modules = exportConfiguration(":tools", "agp", offlineRoot)
file("${offlineRoot.absolutePath}/.agp-offline-complete").writeText(
"agpVersion=$agpVersion\nmodules=$modules\n",
)
@@ -124,13 +110,14 @@ tasks.register("exportOfflineMaven") {
}
tasks.register("exportAllOfflineMaven") {
dependsOn(configurations.named("agp"), configurations.named("androidDeps"), configurations.named("buildPlugins"))
dependsOn(":tools:compileJava", ":app:preBuild")
doLast {
val offlineRoot = file("${rootProject.projectDir}/../offline-maven").apply { mkdirs() }
val modules =
exportConfiguration("agp", offlineRoot) +
exportConfiguration("androidDeps", offlineRoot) +
exportConfiguration("buildPlugins", offlineRoot)
var modules = 0
modules += exportConfiguration(":tools", "agp", offlineRoot)
modules += exportConfiguration(":tools", "buildPlugins", offlineRoot)
modules += exportAndroidRuntimeClasspath(offlineRoot)
file("${offlineRoot.absolutePath}/.agp-offline-complete").writeText(
"agpVersion=$agpVersion\nmodules=$modules\n",
)