@@ -43,8 +43,6 @@ class GradleService(val editor: Editor) {
4343
4444 val folder: File get() = editor.sketch.folder
4545
46- // TODO: Capture output & enable at start of running
47-
4846 fun prepare (){
4947 Messages .log(" Preparing sketch" )
5048 if (preparing) return
@@ -72,6 +70,8 @@ class GradleService(val editor: Editor) {
7270 .addProgressListener(listOf (" :run" ))
7371 .forTasks(" run" )
7472 .withCancellationToken(cancel.token())
73+ .setStandardError(editor.console.err)
74+ .setStandardOutput(editor.console.out )
7575 .run ()
7676 Messages .log(" Running finished" )
7777 }
@@ -86,6 +86,8 @@ class GradleService(val editor: Editor) {
8686 .addProgressListener(listOf (" :runDistributable" ))
8787 .forTasks(" runDistributable" )
8888 .withCancellationToken(cancel.token())
89+ .setStandardError(editor.console.err)
90+ .setStandardOutput(editor.console.out )
8991 .run ()
9092 Messages .log(" Exporting finished" )
9193 }
@@ -186,7 +188,7 @@ class GradleService(val editor: Editor) {
186188 return this
187189 }
188190
189- private fun ProjectConnection.newSketchBuild (): BuildLauncher {
191+ private fun ProjectConnection.newSketchBuild (): BuildLauncher {
190192 finishedTasks.clear()
191193
192194 val workingDir = kotlin.io.path.createTempDirectory()
@@ -196,7 +198,7 @@ class GradleService(val editor: Editor) {
196198 // TODO: is this the best way to handle unsaved data?
197199 val unsaved = mutableListOf<String >()
198200 editor.sketch.code.forEach { code ->
199- if (! code.isModified) return @forEach
201+ if (! code.isModified) return @forEach
200202
201203 val file = workingDir.resolve(" unsaved/${code.fileName} " )
202204 file.parent.toFile().mkdirs()
@@ -237,10 +239,9 @@ class GradleService(val editor: Editor) {
237239 }
238240
239241
240-
241242 val buildGradle = folder.resolve(" build.gradle.kts" )
242243 // TODO: Manage script if the comment exists
243- if (! buildGradle.exists()){
244+ if (! buildGradle.exists()) {
244245 Messages .log(" build.gradle.kts not found in ${folder} , creating one" )
245246 // TODO: Allow for other plugins to be registered
246247 // TODO: Allow for the whole configuration to be overridden
@@ -256,18 +257,17 @@ class GradleService(val editor: Editor) {
256257 buildGradle.writeText(content)
257258 }
258259 val settingsGradle = folder.resolve(" settings.gradle.kts" )
259- if (! settingsGradle.exists()) {
260+ if (! settingsGradle.exists()) {
260261 settingsGradle.createNewFile()
261262 }
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" )
262267
268+ arguments.addAll(variables.entries.map { " -Pprocessing.${it.key} =${it.value} " })
263269 return this .newBuild()
264- // .addJvmArguments("-Xmx2g")
265270 .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())
272272 }
273273}
0 commit comments