Skip to content

Commit 36ce0ab

Browse files
committed
Runner: Fixing build errors
1 parent 701f9f5 commit 36ce0ab

File tree

8 files changed

+31
-49
lines changed

8 files changed

+31
-49
lines changed

app/ant/processing/app/gradle/GradleService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
public class GradleService {
66
public GradleService(Editor editor) { }
77

8+
public void setEnabled(boolean enabled) {}
9+
public boolean getEnabled() { return false; }
810
public void prepare(){}
911
public void run() {}
1012
public void export(){}

app/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ tasks.register("generateSnapConfiguration"){
255255
- openjdk-17-jre
256256
override-prime: |
257257
snapcraftctl prime
258-
chmod -R +x opt/processing/lib/app/resources/jdk-*
259258
rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts
260259
""".trimIndent()
261260
dir.file("../snapcraft.yaml").asFile.writeText(content)
@@ -271,7 +270,7 @@ tasks.register<Exec>("packageSnap"){
271270
commandLine("snapcraft")
272271
}
273272
tasks.register<Zip>("zipDistributable"){
274-
dependsOn("createDistributable", "setExecutablePermissions")
273+
dependsOn("createDistributable")
275274
group = "compose desktop"
276275

277276
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()

app/src/processing/app/gradle/GradleJob.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,21 @@ open abstract class GradleJob{
102102
if(event !is TaskStartEvent) return@ProgressListener
103103
if(event.descriptor.name != ":run") return@ProgressListener
104104

105-
Messages.log("Attaching to VM")
106-
val connector = Bootstrap.virtualMachineManager().allConnectors()
107-
.firstOrNull { it.name() == "com.sun.jdi.SocketAttach" }
108-
as AttachingConnector?
109-
?: return@ProgressListener
110-
val args = connector.defaultArguments()
111-
args["port"]?.setValue(service?.debugPort.toString())
112-
val sketch = connector.attach(args)
113-
vm.value = sketch
114-
Messages.log("Attached to VM: ${sketch.name()}")
105+
// TODO: Why doesn't the debugger attach if not run with a debugger itself?
106+
try {
107+
Messages.log("Attaching to VM")
108+
val connector = Bootstrap.virtualMachineManager().allConnectors()
109+
.firstOrNull { it.name() == "com.sun.jdi.SocketAttach" }
110+
as AttachingConnector?
111+
?: throw IllegalStateException("No socket attach connector found")
112+
val args = connector.defaultArguments()
113+
args["port"]?.setValue(service?.debugPort.toString())
114+
val sketch = connector.attach(args)
115+
vm.value = sketch
116+
Messages.log("Attached to VM: ${sketch.name()}")
117+
}catch (e: Exception){
118+
Messages.log("Error while attaching to VM: ${e.message}")
119+
}
115120
})
116121
return this
117122
}

app/src/processing/app/gradle/ScreenshotService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import java.nio.file.Path
1111
import kotlin.time.Duration.Companion.seconds
1212
import kotlin.time.TimeSource
1313

14+
//TODO: Move to java mode
1415
class ScreenshotService {
1516
companion object{
1617
fun takeScreenshot(vm: VirtualMachine, onComplete: (Path) -> Unit) {

app/src/processing/app/gradle/ui/Toolbar.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class Toolbar(val editor: Editor) {
119119

120120
}
121121

122+
//TODO: Indicate waiting for vm connection to be ready
122123
val vm = editor.service.jobs.lastOrNull()?.vm?.value
123124
vm?.apply {
124125
ActionButton(

java/gradle/src/main/kotlin/ProcessingPlugin.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
4646
prefs.setProperty("export.application.stop", "false")
4747
if(preferences.exists()) prefs.store(preferences.outputStream(), null)
4848

49-
val sketchbook = prefs.getProperty("sketchbook.path.four") ?: ("${System.getProperty("user.home")}/.processing")
49+
val sketchbook = project.findProperty("processing.sketchbook") as String?
50+
?: prefs.getProperty("sketchbook.path.four")
51+
?: ("${System.getProperty("user.home")}/.processing")
5052

5153
// Apply the Java plugin to the Project
5254
project.plugins.apply(JavaPlugin::class.java)

java/gradle/src/main/kotlin/ProcessingTask.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import java.util.concurrent.Callable
1010
import java.util.jar.JarFile
1111
import javax.inject.Inject
1212

13+
14+
// TODO: Rename to PDE Task
1315
abstract class ProcessingTask : SourceTask() {
1416
@get:OutputDirectory
1517
var outputDirectory: File? = null
@@ -33,10 +35,10 @@ abstract class ProcessingTask : SourceTask() {
3335

3436
@TaskAction
3537
fun execute(inputChanges: InputChanges) {
36-
// Using stableSources since we can only run the pre-processor on the full set of sources
37-
// TODO: Allow pre-processor to run on individual files
38+
// TODO: Allow pre-processor to run on individual files (future)
39+
// TODO: Only compare file names from both defined roots (e.g. sketch.pde and folder/sketch.pde should both be included)
3840

39-
// TODO: Only compare file names from both defined roots
41+
// Using stableSources since we can only run the pre-processor on the full set of sources
4042
val combined = stableSources
4143
.files
4244
.groupBy { it.name }
@@ -58,8 +60,10 @@ abstract class ProcessingTask : SourceTask() {
5860
javaFile.flush()
5961
javaFile.close()
6062

61-
// Scan all the libaries in the sketchbook
6263
// TODO: Move scanning the libraries to a separate task to avoid running this every time
64+
// TODO: Support library changes
65+
// TODO: Add internal libraries (dxf, serial, etc..)
66+
// Scan all the libaries in the sketchbook
6367
val libraries = File(sketchBook, "libraries")
6468
.listFiles { file -> file.isDirectory }
6569
?.map { folder ->

java/gradle/src/test/kotlin/ProcessingPluginTest.kt

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,4 @@ class ProcessingPluginTest{
1313

1414
assert(project.tasks.getByName("sketch") is Task)
1515
}
16-
@JvmField
17-
@Rule
18-
val folder: TemporaryFolder = TemporaryFolder()
19-
20-
@Test
21-
fun testPluginOutcome() {
22-
23-
val buildFile = folder.newFile("build.gradle.kts")
24-
buildFile.writeText("""
25-
plugins{
26-
id("org.processing.gradle")
27-
}
28-
""".trimIndent())
29-
30-
val sketchFile = folder.newFile("sketch.pde")
31-
sketchFile.writeText("""
32-
void setup(){
33-
size(100, 100);
34-
}
35-
void draw(){
36-
background(0);
37-
}
38-
""".trimIndent())
39-
40-
GradleRunner.create()
41-
.withProjectDir(folder.root)
42-
.withArguments("build")
43-
.withPluginClasspath()
44-
.build()
45-
46-
assert(folder.root.resolve("build/generated/pde/main").exists())
47-
}
4816
}

0 commit comments

Comments
 (0)