@@ -2,6 +2,10 @@ package processing.app.gradle
22
33import androidx.compose.runtime.mutableStateListOf
44import androidx.compose.runtime.mutableStateOf
5+ import androidx.compose.runtime.snapshotFlow
6+ import kotlinx.coroutines.CoroutineScope
7+ import kotlinx.coroutines.Dispatchers
8+ import kotlinx.coroutines.launch
59import org.gradle.tooling.BuildLauncher
610import processing.app.Base
711import processing.app.Language
@@ -46,38 +50,32 @@ class GradleService(
4650 val workingDir = createTempDirectory()
4751 val debugPort = (30_000 .. 60_000 ).random()
4852
49- // TODO: Add support for present
5053 fun run (){
51- stopActions()
52-
53- val job = GradleJob ()
54- job.service = this
55- job.configure = {
56- setup()
57- forTasks(" run" )
58- }
59- jobs.add(job)
60- job.start()
54+ startAction(" run" )
6155 }
6256
6357 fun export (){
58+ startAction(" runDistributable" )
59+ }
60+
61+ fun stop (){
6462 stopActions()
63+ }
64+
65+ private fun startAction (vararg tasks : String ) {
66+ if (! active.value) return
6567
6668 val job = GradleJob ()
6769 job.service = this
6870 job.configure = {
6971 setup()
70- forTasks(" runDistributable " )
72+ forTasks(tasks.joinToString( " " ) )
7173 }
7274 jobs.add(job)
7375 job.start()
7476 }
7577
76- fun stop (){
77- stopActions()
78- }
79-
80- fun stopActions (){
78+ private fun stopActions (){
8179 jobs
8280 .forEach(GradleJob ::cancel)
8381 }
@@ -108,7 +106,7 @@ class GradleService(
108106 " settings" to Platform .getSettingsFolder().absolutePath.toString(),
109107 " unsaved" to unsaved.joinToString(" ," ),
110108 " debugPort" to debugPort.toString(),
111- " fullscreen" to false , // TODO: Implement
109+ " fullscreen" to System .getProperty( " processing.fullscreen " , " false " ).equals( " true " ),
112110 " display" to 1 , // TODO: Implement
113111 " external" to true ,
114112 " location" to null , // TODO: Implement
0 commit comments