-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create BUILT_PRODUCTS_DIR if needed when running in PreAction scripts
^KT-71423
- Loading branch information
1 parent
332753b
commit 1ca814e
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../common/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/apple/CreateBuildSystemDirectory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. | ||
*/ | ||
|
||
package org.jetbrains.kotlin.gradle.plugin.mpp.apple | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Optional | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.process.ExecOperations | ||
import org.gradle.work.DisableCachingByDefault | ||
import org.jetbrains.kotlin.incremental.createDirectory | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
/** | ||
* When running Gradle in PreAction scripts we sometimes have to create BUILT_PRODUCTS_DIR if build system didn't create it | ||
*/ | ||
@DisableCachingByDefault(because = "This task only copies files") | ||
internal abstract class CreateBuildSystemDirectory @Inject constructor( | ||
private val execOperations: ExecOperations, | ||
) : DefaultTask() { | ||
|
||
@get:Optional | ||
@get:Input | ||
abstract val buildSystemDirectory: Property<File> | ||
|
||
@TaskAction | ||
fun create() { | ||
val buildSystemDirectory = this.buildSystemDirectory.orNull ?: return | ||
if (buildSystemDirectory.exists()) return | ||
|
||
buildSystemDirectory.createDirectory() | ||
|
||
// Mark the directory with this attribute to allow Xcode build system to remove it | ||
execOperations.exec { | ||
it.commandLine( | ||
"/usr/bin/xattr", "-w", "com.apple.xcode.CreatedByBuildSystem", "true", buildSystemDirectory, | ||
) | ||
}.assertNormalExitValue() | ||
} | ||
|
||
} |