feat: bundle dex
file into jar
file (#359)
This commit is contained in:
parent
b679fcf6a2
commit
1d084917ae
|
@ -31,9 +31,6 @@
|
||||||
"assets": [
|
"assets": [
|
||||||
{
|
{
|
||||||
"path": "build/libs/*.jar"
|
"path": "build/libs/*.jar"
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "build/libs/*.dex"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,15 +27,14 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
register<DefaultTask>("generateDex") {
|
register<DefaultTask>("generateBundle") {
|
||||||
description = "Generate dex files from build"
|
description = "Generate dex files from build and bundle them in the jar file"
|
||||||
dependsOn(build)
|
dependsOn(build)
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
val androidHome = System.getenv("ANDROID_HOME") ?: throw GradleException("ANDROID_HOME not found")
|
val androidHome = System.getenv("ANDROID_HOME") ?: throw GradleException("ANDROID_HOME not found")
|
||||||
val d8 = "${androidHome}/build-tools/32.0.0/d8"
|
val d8 = "${androidHome}/build-tools/32.0.0/d8"
|
||||||
val input = configurations.archives.get().allArtifacts.files.files.first().absolutePath
|
val input = configurations.archives.get().allArtifacts.files.files.first().absolutePath
|
||||||
val output = input.replace(".jar", ".dex")
|
|
||||||
val work = File("${buildDir}/libs")
|
val work = File("${buildDir}/libs")
|
||||||
|
|
||||||
exec {
|
exec {
|
||||||
|
@ -45,7 +44,7 @@ tasks {
|
||||||
|
|
||||||
exec {
|
exec {
|
||||||
workingDir = work
|
workingDir = work
|
||||||
commandLine = listOf("mv", "classes.dex", output)
|
commandLine = listOf("zip", "-u", input, "classes.dex")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +61,6 @@ tasks {
|
||||||
register<DefaultTask>("publish") {
|
register<DefaultTask>("publish") {
|
||||||
group = "publish"
|
group = "publish"
|
||||||
description = "Dummy task"
|
description = "Dummy task"
|
||||||
dependsOn(named("generateDex"), named("generateReadme"))
|
dependsOn(named("generateBundle"), named("generateReadme"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue