[Build] Fix configuration cache issues (part 5)
Make Project.configureFormInstrumentation and Task.useAndroidConfiguration extensions, :dependencies:android-sdk unzip tasks compatible with configuration cache Relates to #KT-44611
This commit is contained in:
+14
-8
@@ -1,3 +1,4 @@
|
||||
import org.gradle.configurationcache.extensions.serviceOf
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
import java.net.URI
|
||||
|
||||
@@ -72,22 +73,27 @@ fun unzipSdkTask(
|
||||
additionalConfig: Configuration? = null, dirLevelsToSkipOnUnzip: Int = 0, ext: String = "zip",
|
||||
prepareTask: TaskProvider<DefaultTask> = prepareSdk,
|
||||
unzipFilter: CopySpec.() -> Unit = {}
|
||||
): Task {
|
||||
): TaskProvider<Task> {
|
||||
val id = "${sdkName}_$sdkVer"
|
||||
val cfg = configurations.create(id)
|
||||
val createdCfg = configurations.create(id)
|
||||
val dependency = "google:$sdkName:$sdkVer${coordinatesSuffix.takeIf { it.isNotEmpty() }?.let { ":$it" } ?: ""}@$ext"
|
||||
dependencies.add(cfg.name, dependency)
|
||||
dependencies.add(createdCfg.name, dependency)
|
||||
|
||||
val unzipTask = task("unzip_$id") {
|
||||
val sdkDestDir = sdkDestDir
|
||||
val unzipTask = tasks.register("unzip_$id") {
|
||||
val cfg = project.configurations.getByName(id)
|
||||
dependsOn(cfg)
|
||||
inputs.files(cfg)
|
||||
val targetDir = file("$sdkDestDir/$destinationSubdir")
|
||||
val targetDir = project.file("$sdkDestDir/$destinationSubdir")
|
||||
outputs.dirs(targetDir)
|
||||
val fs = project.serviceOf<FileSystemOperations>()
|
||||
val archiveOperations = project.serviceOf<ArchiveOperations>()
|
||||
val file = cfg.singleFile
|
||||
doFirst {
|
||||
project.copy {
|
||||
fs.copy {
|
||||
when (ext) {
|
||||
"zip" -> from(zipTree(cfg.singleFile))
|
||||
"tar.gz" -> from(tarTree(resources.gzip(cfg.singleFile)))
|
||||
"zip" -> from(archiveOperations.zipTree(file))
|
||||
"tar.gz" -> from(archiveOperations.tarTree(project.resources.gzip(file)))
|
||||
else -> throw GradleException("Don't know how to handle the extension \"$ext\"")
|
||||
}
|
||||
unzipFilter.invoke(this)
|
||||
|
||||
Reference in New Issue
Block a user