Skip to content

Commit

Permalink
Optimize artifacts copy task (LawnchairLauncher#3842)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Dec 17, 2023
1 parent c383fad commit 4497077
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import app.cash.licensee.LicenseeTask
import com.android.build.gradle.api.AndroidBasePlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

Expand Down Expand Up @@ -137,17 +138,22 @@ android {
buildConfigField "int", "QUICKSTEP_MAX_SDK", quickstepMaxSdk
}

applicationVariants.configureEach { variant ->
def capitalizedName = variant.name.capitalize()
def copyArtifactList = tasks.register("copy${capitalizedName}ArtifactList", Copy) {
dependsOn tasks.named("licenseeAndroid${capitalizedName}")
from reporting.file("licensee/android${capitalizedName}/artifacts.json")
into layout.buildDirectory.dir("generated/dependencyAssets/")
}
tasks.named("merge${variant.name.capitalize()}Assets").configure {
dependsOn copyArtifactList
androidComponents {
onVariants(selector().all()) { variant ->
def capName = variant.name.capitalize()
def licenseeTask = tasks.named("licenseeAndroid$capName", LicenseeTask)
def copyArtifactsTask = tasks.register("copy${capName}Artifacts", Copy) {
dependsOn(licenseeTask)
from(licenseeTask.map { it.outputDir.file("artifacts.json") })
into(layout.buildDirectory.dir("generated/dependencyAssets"))
}
variant.sources.assets?.addGeneratedSourceDirectory(licenseeTask) {
objects.directoryProperty().fileProvider(copyArtifactsTask.map { it.destinationDir })
}
}
}

applicationVariants.configureEach { variant ->
variant.outputs.configureEach {
outputFileName = "Lawnchair ${variant.versionName}.apk"
}
Expand Down

0 comments on commit 4497077

Please sign in to comment.