diff --git a/build.gradle b/build.gradle index 211a68f23bf..8214e023ab7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,4 @@ +import app.cash.licensee.LicenseeTask import com.android.build.gradle.api.AndroidBasePlugin import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -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" }