[Gradle] Support Configuration Cache for FatFramework task

^KT-54362
^KT-54339 Verification Pending
This commit is contained in:
Anton Lakotka
2022-10-11 10:34:19 +02:00
committed by Space Team
parent a7f33819fa
commit 13dcb9388c
2 changed files with 19 additions and 9 deletions
@@ -90,7 +90,7 @@ open class PodInstallTask : CocoapodsTask() {
val podInstallCommand = listOf("pod", "install")
runCommand(podInstallCommand,
project.logger,
logger,
errorHandler = { returnCode, output, _ ->
CocoapodsErrorHandlingUtil.handlePodInstallError(
podInstallCommand.joinToString(" "),
@@ -7,8 +7,11 @@
package org.jetbrains.kotlin.gradle.tasks
import org.gradle.api.DefaultTask
import org.gradle.api.file.FileSystemOperations
import org.gradle.api.file.FileTree
import org.gradle.api.model.ObjectFactory
import org.gradle.api.tasks.*
import org.gradle.process.ExecOperations
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
@@ -23,6 +26,7 @@ import org.jetbrains.kotlin.konan.util.visibleName
import java.io.ByteArrayOutputStream
import java.io.File
import java.nio.file.Files
import javax.inject.Inject
class FrameworkDsymLayout(val rootDir: File) {
init {
@@ -110,7 +114,13 @@ class FrameworkDescriptor(
/**
* Task running lipo to create a fat framework from several simple frameworks. It also merges headers, plists and module files.
*/
open class FatFrameworkTask : DefaultTask() {
open class FatFrameworkTask
@Inject
internal constructor(
private val execOperations: ExecOperations,
private val fileOperations: FileSystemOperations,
private val objectFactory: ObjectFactory,
) : DefaultTask() {
init {
onlyIf { HostManager.hostIsMac }
}
@@ -150,7 +160,7 @@ open class FatFrameworkTask : DefaultTask() {
@get:InputFiles
@get:SkipWhenEmpty
protected val inputFrameworkFiles: Iterable<FileTree>
get() = frameworks.map { project.fileTree(it.file) }
get() = frameworks.map { objectFactory.fileTree().from(it.file) }
@get:PathSensitive(PathSensitivity.ABSOLUTE)
@get:IgnoreEmptyDirectories
@@ -160,7 +170,7 @@ open class FatFrameworkTask : DefaultTask() {
framework.files.dSYM.takeIf {
it.exists()
}?.rootDir?.let {
project.fileTree(it)
objectFactory.fileTree().from(it)
}
}
@@ -266,7 +276,7 @@ open class FatFrameworkTask : DefaultTask() {
val commands = mutableListOf<String>()
var ignoreExitValue = false
fun run() = project.exec { exec ->
fun run() = execOperations.exec { exec ->
exec.executable = "/usr/libexec/PlistBuddy"
commands.forEach {
exec.args("-c", it)
@@ -285,7 +295,7 @@ open class FatFrameworkTask : DefaultTask() {
}
private fun runLipo(inputFiles: Collection<File>, outputFile: File) =
project.exec { exec ->
execOperations.exec { exec ->
exec.executable = "/usr/bin/lipo"
exec.args = listOf(
"-create",
@@ -295,7 +305,7 @@ open class FatFrameworkTask : DefaultTask() {
}
private fun runInstallNameTool(file: File, frameworkName: String) {
project.exec { exec ->
execOperations.exec { exec ->
exec.executable = "install_name_tool"
exec.args = listOf(
"-id",
@@ -362,7 +372,7 @@ open class FatFrameworkTask : DefaultTask() {
// Use Info.plist of one of the frameworks to get basic data.
val baseInfo = frameworks.first().files.infoPlist
project.copy {
fileOperations.copy {
it.from(baseInfo)
it.into(outputFile.parentFile)
}
@@ -413,7 +423,7 @@ open class FatFrameworkTask : DefaultTask() {
// Copy dSYM's Info.plist.
// It doesn't contain target-specific info or framework names except the bundle id so there is no need to edit it.
// TODO: handle bundle id.
project.copy {
fileOperations.copy {
it.from(dsymInputs.values.first().infoPlist)
it.into(fatDsym.infoPlist.parentFile)
}