@@ -154,29 +154,38 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
154154
155155 }
156156
157+ // For every Java Source Set (main, test, etc) add a PDE source set that includes .pde files
158+ // and a task to process them before compilation
157159 project.extensions.getByType(JavaPluginExtension ::class .java).sourceSets.first().let { sourceSet ->
158160 val pdeSourceSet = objectFactory.newInstance(
159161 DefaultPDESourceDirectorySet ::class .java,
160162 objectFactory.sourceDirectorySet(" ${sourceSet.name} .pde" , " ${sourceSet.name} Processing Source" )
161- ).apply {
162- filter.include(" **/*.pde" )
163- filter.exclude(" ${project.layout.buildDirectory.asFile.get().name} /**" )
163+ )
164164
165+ // Configure the PDE source set to include all .pde files in the sketch folder except those in the build directory
166+ pdeSourceSet.apply {
165167 srcDir(" ./" )
166168 srcDir(" $workingDir /unsaved" )
169+
170+ filter.include(" **/*.pde" )
171+ filter.exclude(" ${project.layout.buildDirectory.asFile.get().name} /**" )
167172 }
168173 sourceSet.allSource.source(pdeSourceSet)
174+
175+ // Add top level java source files
169176 sourceSet.java.srcDir(project.layout.projectDirectory).apply {
170177 include(" /*.java" )
171178 }
172179
180+ // Scan the libraries before compiling the sketches
173181 val librariesTaskName = sourceSet.getTaskName(" scanLibraries" , " PDE" )
174182 val librariesScan = project.tasks.register(librariesTaskName, LibrariesTask ::class .java) { task ->
175183 task.description = " Scans the libraries in the sketchbook"
176184 task.librariesDirectory.set(sketchbook?.let { File (it, " libraries" ) })
177185 // TODO: Save the libraries metadata to settings folder to share between sketches
178186 }
179187
188+ // Create a task to process the .pde files before compiling the java sources
180189 val pdeTaskName = sourceSet.getTaskName(" preprocess" , " PDE" )
181190 val pdeTask = project.tasks.register(pdeTaskName, PDETask ::class .java) { task ->
182191 task.description = " Processes the ${sourceSet.name} PDE"
@@ -194,7 +203,7 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
194203 // TODO: Save the libraries metadata to settings folder to share between sketches
195204 }
196205
197- // Make sure that the PDE task runs before the java compilation task
206+ // Make sure that the PDE tasks runs before the java compilation task
198207 project.tasks.named(sourceSet.compileJavaTaskName) { task ->
199208 task.dependsOn(pdeTaskName, depsTaskName)
200209 }
0 commit comments