@@ -13,13 +13,14 @@ import org.gradle.api.tasks.Optional
13
13
import org.gradle.api.tasks.OutputDirectory
14
14
import org.gradle.api.tasks.OutputFile
15
15
import org.gradle.api.tasks.TaskAction
16
+ import org.gradle.process.ExecOperations
16
17
import java.io.ByteArrayOutputStream
17
18
import java.io.File
18
19
import java.math.BigInteger
19
20
import java.security.MessageDigest
20
21
import javax.inject.Inject
21
22
22
- open class CompileSwiftTask @Inject constructor(
23
+ abstract class CompileSwiftTask @Inject constructor(
23
24
@Input val cinteropName : String ,
24
25
@Input val compileTarget : CompileTarget ,
25
26
@Input val buildDirectory : String ,
@@ -45,6 +46,9 @@ open class CompileSwiftTask @Inject constructor(
45
46
val defFile
46
47
get() = File (targetDir, " $cinteropName .def" )
47
48
49
+ @get:Inject
50
+ abstract val execOperations: ExecOperations
51
+
48
52
@TaskAction
49
53
fun produce () {
50
54
val packageName: String = packageNameProperty.get()
@@ -108,7 +112,7 @@ open class CompileSwiftTask @Inject constructor(
108
112
logger.info(" Working directory: $swiftBuildDir " )
109
113
logger.info(" xcrun ${args.joinToString(" " )} " )
110
114
111
- project .exec {
115
+ execOperations .exec {
112
116
it.executable = " xcrun"
113
117
it.workingDir = swiftBuildDir
114
118
it.args = args
@@ -163,7 +167,7 @@ open class CompileSwiftTask @Inject constructor(
163
167
private fun readSdkPath (): String {
164
168
val stdout = ByteArrayOutputStream ()
165
169
166
- project .exec {
170
+ execOperations .exec {
167
171
it.executable = " xcrun"
168
172
it.args = listOf (
169
173
" --sdk" ,
@@ -179,7 +183,7 @@ open class CompileSwiftTask @Inject constructor(
179
183
private fun readXcodeMajorVersion (): Int {
180
184
val stdout = ByteArrayOutputStream ()
181
185
182
- project .exec {
186
+ execOperations .exec {
183
187
it.executable = " xcodebuild"
184
188
it.args = listOf (" -version" )
185
189
it.standardOutput = stdout
@@ -195,7 +199,7 @@ open class CompileSwiftTask @Inject constructor(
195
199
private fun readXcodePath (): String {
196
200
val stdout = ByteArrayOutputStream ()
197
201
198
- project .exec {
202
+ execOperations .exec {
199
203
it.executable = " xcode-select"
200
204
it.args = listOf (" --print-path" )
201
205
it.standardOutput = stdout
0 commit comments