fix docker for tauri android build
This commit is contained in:
1
tauri_app/docker/agp-resolver/.gitignore
vendored
1
tauri_app/docker/agp-resolver/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.gradle/
|
||||
build/
|
||||
offline-gradle/*.zip
|
||||
local.properties
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
38
tauri_app/docker/agp-resolver/app/build.gradle.kts
Normal file
38
tauri_app/docker/agp-resolver/app/build.gradle.kts
Normal file
@@ -0,0 +1,38 @@
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "ru.lendry.offline.resolver"
|
||||
compileSdk = 35
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "ru.lendry.offline.resolver"
|
||||
minSdk = 24
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
// Mirror Tauri Android app dependencies (apps + typical plugin transitives).
|
||||
dependencies {
|
||||
implementation("androidx.webkit:webkit:1.14.0")
|
||||
implementation("androidx.appcompat:appcompat:1.7.1")
|
||||
implementation("androidx.activity:activity-ktx:1.10.1")
|
||||
implementation("com.google.android.material:material:1.12.0")
|
||||
implementation("androidx.lifecycle:lifecycle-process:2.10.0")
|
||||
implementation("androidx.browser:browser:1.8.0")
|
||||
implementation("androidx.core:core-ktx:1.13.0")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application android:label="OfflineResolver" />
|
||||
</manifest>
|
||||
@@ -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",
|
||||
)
|
||||
|
||||
@@ -650,7 +650,7 @@ code + .copy-button {
|
||||
<script type="text/javascript">
|
||||
function configurationCacheProblems() { return (
|
||||
// begin-report-data
|
||||
{"diagnostics":[{"locations":[{},{"taskPath":":exportAllOfflineMaven"}],"problem":[{"text":"Using method exec(Action) has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 9.0."}],"contextualLabel":"Using method exec(Action) has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#deprecated_project_exec","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"using-method-exec-action-has-been-deprecated","displayName":"Using method exec(Action) has been deprecated."}],"solutions":[[{"text":"Use ExecOperations.exec(Action) or ProviderFactory.exec(Action) instead."}]]},{"locations":[{},{"taskPath":":exportAllOfflineMaven"}],"problem":[{"text":"Using method exec(Action) has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 9.0."}],"contextualLabel":"Using method exec(Action) has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#deprecated_project_exec","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"using-method-exec-action-has-been-deprecated","displayName":"Using method exec(Action) has been deprecated."}],"solutions":[[{"text":"Use ExecOperations.exec(Action) or ProviderFactory.exec(Action) instead."}]]}],"problemsReport":{"totalProblemCount":2,"buildName":"agp-resolver","requestedTasks":"exportAllOfflineMaven","documentationLink":"https://docs.gradle.org/8.14.3/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
|
||||
{"diagnostics":[{"locations":[{},{"pluginId":"org.jetbrains.kotlin.android"}],"problem":[{"text":"The StartParameter.isConfigurationCacheRequested property has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"The StartParameter.isConfigurationCacheRequested property has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#deprecated_startparameter_is_configuration_cache_requested","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"the-startparameter-isconfigurationcacherequested-property-has-been-deprecated","displayName":"The StartParameter.isConfigurationCacheRequested property has been deprecated."}],"solutions":[[{"text":"Please use 'configurationCache.requested' property on 'BuildFeatures' service instead."}]]},{"locations":[{},{"pluginId":"org.jetbrains.kotlin.android"}],"problem":[{"text":"The StartParameter.isConfigurationCacheRequested property has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"The StartParameter.isConfigurationCacheRequested property has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#deprecated_startparameter_is_configuration_cache_requested","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"the-startparameter-isconfigurationcacherequested-property-has-been-deprecated","displayName":"The StartParameter.isConfigurationCacheRequested property has been deprecated."}],"solutions":[[{"text":"Please use 'configurationCache.requested' property on 'BuildFeatures' service instead."}]]},{"locations":[{},{"taskPath":":exportAllOfflineMaven"}],"problem":[{"text":"Using method exec(Action) has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 9.0."}],"contextualLabel":"Using method exec(Action) has been deprecated.","documentationLink":"https://docs.gradle.org/8.14.3/userguide/upgrading_version_8.html#deprecated_project_exec","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"using-method-exec-action-has-been-deprecated","displayName":"Using method exec(Action) has been deprecated."}],"solutions":[[{"text":"Use ExecOperations.exec(Action) or ProviderFactory.exec(Action) instead."}]]}],"problemsReport":{"totalProblemCount":3,"buildName":"agp-resolver","requestedTasks":"exportAllOfflineMaven","documentationLink":"https://docs.gradle.org/8.14.3/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
|
||||
// end-report-data
|
||||
);}
|
||||
</script>
|
||||
|
||||
3
tauri_app/docker/agp-resolver/gradle.properties
Normal file
3
tauri_app/docker/agp-resolver/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
|
||||
android.useAndroidX=true
|
||||
android.nonTransitiveRClass=true
|
||||
@@ -6,4 +6,11 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.android.application") version "8.11.0" apply false
|
||||
id("org.jetbrains.kotlin.android") version "1.9.25" apply false
|
||||
}
|
||||
|
||||
rootProject.name = "agp-resolver"
|
||||
include(":app")
|
||||
include(":tools")
|
||||
|
||||
21
tauri_app/docker/agp-resolver/tools/build.gradle.kts
Normal file
21
tauri_app/docker/agp-resolver/tools/build.gradle.kts
Normal file
@@ -0,0 +1,21 @@
|
||||
plugins {
|
||||
java
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
val agpVersion: String = providers.gradleProperty("agpVersion").orElse("8.11.0").get()
|
||||
|
||||
configurations {
|
||||
create("agp")
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user