Skip to content

Commit 1be42b3

Browse files
committed
[configuration-cache] use ExecOperations instead of project.exec
1 parent 182e2fc commit 1be42b3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

plugin/src/main/kotlin/io/github/ttypic/swiftklib/gradle/task/CompileSwiftTask.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import org.gradle.api.tasks.Optional
1313
import org.gradle.api.tasks.OutputDirectory
1414
import org.gradle.api.tasks.OutputFile
1515
import org.gradle.api.tasks.TaskAction
16+
import org.gradle.process.ExecOperations
1617
import java.io.ByteArrayOutputStream
1718
import java.io.File
1819
import java.math.BigInteger
1920
import java.security.MessageDigest
2021
import javax.inject.Inject
2122

22-
open class CompileSwiftTask @Inject constructor(
23+
abstract class CompileSwiftTask @Inject constructor(
2324
@Input val cinteropName: String,
2425
@Input val compileTarget: CompileTarget,
2526
@Input val buildDirectory: String,
@@ -45,6 +46,9 @@ open class CompileSwiftTask @Inject constructor(
4546
val defFile
4647
get() = File(targetDir, "$cinteropName.def")
4748

49+
@get:Inject
50+
abstract val execOperations: ExecOperations
51+
4852
@TaskAction
4953
fun produce() {
5054
val packageName: String = packageNameProperty.get()
@@ -108,7 +112,7 @@ open class CompileSwiftTask @Inject constructor(
108112
logger.info("Working directory: $swiftBuildDir")
109113
logger.info("xcrun ${args.joinToString(" ")}")
110114

111-
project.exec {
115+
execOperations.exec {
112116
it.executable = "xcrun"
113117
it.workingDir = swiftBuildDir
114118
it.args = args
@@ -163,7 +167,7 @@ open class CompileSwiftTask @Inject constructor(
163167
private fun readSdkPath(): String {
164168
val stdout = ByteArrayOutputStream()
165169

166-
project.exec {
170+
execOperations.exec {
167171
it.executable = "xcrun"
168172
it.args = listOf(
169173
"--sdk",
@@ -179,7 +183,7 @@ open class CompileSwiftTask @Inject constructor(
179183
private fun readXcodeMajorVersion(): Int {
180184
val stdout = ByteArrayOutputStream()
181185

182-
project.exec {
186+
execOperations.exec {
183187
it.executable = "xcodebuild"
184188
it.args = listOf("-version")
185189
it.standardOutput = stdout
@@ -195,7 +199,7 @@ open class CompileSwiftTask @Inject constructor(
195199
private fun readXcodePath(): String {
196200
val stdout = ByteArrayOutputStream()
197201

198-
project.exec {
202+
execOperations.exec {
199203
it.executable = "xcode-select"
200204
it.args = listOf("--print-path")
201205
it.standardOutput = stdout

0 commit comments

Comments
 (0)