@@ -43,8 +43,6 @@ class GradleService(val editor: Editor) {
43
43
44
44
val folder: File get() = editor.sketch.folder
45
45
46
- // TODO: Capture output & enable at start of running
47
-
48
46
fun prepare (){
49
47
Messages .log(" Preparing sketch" )
50
48
if (preparing) return
@@ -72,6 +70,8 @@ class GradleService(val editor: Editor) {
72
70
.addProgressListener(listOf (" :run" ))
73
71
.forTasks(" run" )
74
72
.withCancellationToken(cancel.token())
73
+ .setStandardError(editor.console.err)
74
+ .setStandardOutput(editor.console.out )
75
75
.run ()
76
76
Messages .log(" Running finished" )
77
77
}
@@ -86,6 +86,8 @@ class GradleService(val editor: Editor) {
86
86
.addProgressListener(listOf (" :runDistributable" ))
87
87
.forTasks(" runDistributable" )
88
88
.withCancellationToken(cancel.token())
89
+ .setStandardError(editor.console.err)
90
+ .setStandardOutput(editor.console.out )
89
91
.run ()
90
92
Messages .log(" Exporting finished" )
91
93
}
@@ -186,7 +188,7 @@ class GradleService(val editor: Editor) {
186
188
return this
187
189
}
188
190
189
- private fun ProjectConnection.newSketchBuild (): BuildLauncher {
191
+ private fun ProjectConnection.newSketchBuild (): BuildLauncher {
190
192
finishedTasks.clear()
191
193
192
194
val workingDir = kotlin.io.path.createTempDirectory()
@@ -196,7 +198,7 @@ class GradleService(val editor: Editor) {
196
198
// TODO: is this the best way to handle unsaved data?
197
199
val unsaved = mutableListOf<String >()
198
200
editor.sketch.code.forEach { code ->
199
- if (! code.isModified) return @forEach
201
+ if (! code.isModified) return @forEach
200
202
201
203
val file = workingDir.resolve(" unsaved/${code.fileName} " )
202
204
file.parent.toFile().mkdirs()
@@ -237,10 +239,9 @@ class GradleService(val editor: Editor) {
237
239
}
238
240
239
241
240
-
241
242
val buildGradle = folder.resolve(" build.gradle.kts" )
242
243
// TODO: Manage script if the comment exists
243
- if (! buildGradle.exists()){
244
+ if (! buildGradle.exists()) {
244
245
Messages .log(" build.gradle.kts not found in ${folder} , creating one" )
245
246
// TODO: Allow for other plugins to be registered
246
247
// TODO: Allow for the whole configuration to be overridden
@@ -256,18 +257,17 @@ class GradleService(val editor: Editor) {
256
257
buildGradle.writeText(content)
257
258
}
258
259
val settingsGradle = folder.resolve(" settings.gradle.kts" )
259
- if (! settingsGradle.exists()) {
260
+ if (! settingsGradle.exists()) {
260
261
settingsGradle.createNewFile()
261
262
}
263
+ // TODO: Add support for the variables defined in PApplet#9782
264
+
265
+ val arguments = mutableListOf (" --init-script" , initGradle.toAbsolutePath().toString())
266
+ if (! Base .DEBUG ) arguments.add(" --quiet" )
262
267
268
+ arguments.addAll(variables.entries.map { " -Pprocessing.${it.key} =${it.value} " })
263
269
return this .newBuild()
264
- // .addJvmArguments("-Xmx2g")
265
270
.setJavaHome(Platform .getJavaHome())
266
- .withArguments(
267
- " --init-script" , initGradle.toAbsolutePath().toString(),
268
- * variables.entries.map { " -Pprocessing.${it.key} =${it.value} " }.toTypedArray()
269
- )
270
- .setStandardError(System .err)
271
- .setStandardOutput(System .out )
271
+ .withArguments(* arguments.toTypedArray())
272
272
}
273
273
}
0 commit comments