Skip to content

Commit e543238

Browse files
committed
build: move away from removed exec{} to spawn process
1 parent 885ae62 commit e543238

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

Samples/SwiftAndJavaJarSampleLib/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ dependencies {
4646
implementation(project(':SwiftKitCore'))
4747
implementation(project(':SwiftKitFFM'))
4848

49+
testRuntimeOnly("org.junit.platform:junit-platform-launcher") // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512
4950
testImplementation(platform("org.junit:junit-bom:5.10.0"))
5051
testImplementation("org.junit.jupiter:junit-jupiter")
5152
}
@@ -54,16 +55,16 @@ def swiftProductsWithJExtractPlugin() {
5455
def stdout = new ByteArrayOutputStream()
5556
def stderr = new ByteArrayOutputStream()
5657

57-
def result = exec {
58-
commandLine 'swift', 'package', 'describe', '--type', 'json'
59-
standardOutput = stdout
60-
errorOutput = stderr
61-
ignoreExitValue = true
62-
}
58+
def processBuilder = new ProcessBuilder('swift', 'package', 'describe', '--type', 'json')
59+
def process = processBuilder.start()
60+
61+
process.consumeProcessOutput(stdout, stderr)
62+
process.waitFor()
6363

64+
def exitValue = process.exitValue()
6465
def jsonOutput = stdout.toString()
6566

66-
if (result.exitValue == 0) {
67+
if (exitValue == 0) {
6768
def json = new JsonSlurper().parseText(jsonOutput)
6869
def products = json.targets
6970
.findAll { target ->

Samples/SwiftJavaExtractFFMSampleApp/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ def swiftProductsWithJExtractPlugin() {
3939
def stdout = new ByteArrayOutputStream()
4040
def stderr = new ByteArrayOutputStream()
4141

42-
def result = exec {
43-
commandLine 'swift', 'package', 'describe', '--type', 'json'
44-
standardOutput = stdout
45-
errorOutput = stderr
46-
ignoreExitValue = true
47-
}
42+
def processBuilder = new ProcessBuilder('swift', 'package', 'describe', '--type', 'json')
43+
def process = processBuilder.start()
44+
45+
process.consumeProcessOutput(stdout, stderr)
46+
process.waitFor()
4847

48+
def exitValue = process.exitValue()
4949
def jsonOutput = stdout.toString()
5050

51-
if (result.exitValue == 0) {
51+
if (exitValue == 0) {
5252
def json = new JsonSlurper().parseText(jsonOutput)
5353
def products = json.targets
5454
.findAll { target ->
@@ -150,6 +150,7 @@ dependencies {
150150
implementation(project(':SwiftKitCore'))
151151
implementation(project(':SwiftKitFFM'))
152152

153+
testRuntimeOnly("org.junit.platform:junit-platform-launcher") // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512 // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512
153154
testImplementation(platform("org.junit:junit-bom:5.10.0"))
154155
testImplementation("org.junit.jupiter:junit-jupiter")
155156
}

Samples/SwiftJavaExtractJNISampleApp/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def swiftProductsWithJExtractPlugin() {
4040
def stdout = new ByteArrayOutputStream()
4141
def stderr = new ByteArrayOutputStream()
4242

43-
def result = exec {
44-
commandLine 'swift', 'package', 'describe', '--type', 'json'
45-
standardOutput = stdout
46-
errorOutput = stderr
47-
ignoreExitValue = true
48-
}
43+
def processBuilder = new ProcessBuilder('swift', 'package', 'describe', '--type', 'json')
44+
def process = processBuilder.start()
45+
46+
process.consumeProcessOutput(stdout, stderr)
47+
process.waitFor()
4948

49+
def exitValue = process.exitValue()
5050
def jsonOutput = stdout.toString()
5151

52-
if (result.exitValue == 0) {
52+
if (exitValue == 0) {
5353
def json = new JsonSlurper().parseText(jsonOutput)
5454
def products = json.targets
5555
.findAll { target ->
@@ -150,6 +150,7 @@ tasks.clean {
150150
dependencies {
151151
implementation(project(':SwiftKitCore'))
152152

153+
testRuntimeOnly("org.junit.platform:junit-platform-launcher") // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512
153154
testImplementation(platform("org.junit:junit-bom:5.10.0"))
154155
testImplementation("org.junit.jupiter:junit-jupiter")
155156
}

SwiftKitCore/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ tasks.withType(JavaCompile).configureEach {
5353
}
5454

5555
dependencies {
56+
testRuntimeOnly("org.junit.platform:junit-platform-launcher") // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512
5657
testImplementation(platform("org.junit:junit-bom:5.10.0"))
5758
testImplementation("org.junit.jupiter:junit-jupiter")
5859
}

SwiftKitFFM/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ java {
4949
dependencies {
5050
implementation(project(':SwiftKitCore'))
5151

52+
testRuntimeOnly("org.junit.platform:junit-platform-launcher") // TODO: workaround for not finding junit: https://github.com/gradle/gradle/issues/34512
5253
testImplementation(platform("org.junit:junit-bom:5.10.0"))
5354
testImplementation("org.junit.jupiter:junit-jupiter")
5455
}

0 commit comments

Comments
 (0)