mirror of
https://github.com/processing/processing4.git
synced 2026-01-27 10:21:26 +01:00
Adding tests and direct linking
This commit is contained in:
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@@ -26,5 +26,10 @@
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenLocal" />
|
||||
<option name="name" value="MavenLocal" />
|
||||
<option name="url" value="file:$MAVEN_REPOSITORY$/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
@@ -5,8 +5,6 @@ plugins{
|
||||
kotlin("jvm") version libs.versions.kotlin
|
||||
}
|
||||
|
||||
version = rootProject.version
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
@@ -17,12 +15,14 @@ dependencies{
|
||||
implementation(libs.composeGradlePlugin)
|
||||
implementation(libs.kotlinGradlePlugin)
|
||||
implementation(libs.kotlinComposePlugin)
|
||||
|
||||
testImplementation(libs.junit)
|
||||
}
|
||||
|
||||
gradlePlugin{
|
||||
plugins{
|
||||
create("processing"){
|
||||
id = "org.processing.java.gradle"
|
||||
id = "processing.java.gradle"
|
||||
implementationClass = "org.processing.java.gradle.ProcessingPlugin"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
plugins{
|
||||
id("org.processing.java.gradle") version "4.4.0"
|
||||
id("processing.java.gradle")
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
rootProject.name = "processing-gradle-plugin-demo"
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
includeBuild("../../../")
|
||||
}
|
||||
@@ -10,9 +10,7 @@ import org.gradle.api.plugins.JavaPlugin
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.JavaExec
|
||||
import org.jetbrains.compose.ComposeExtension
|
||||
import org.jetbrains.compose.ComposePlugin
|
||||
import org.jetbrains.compose.desktop.DesktopExtension
|
||||
import org.jetbrains.kotlin.konan.properties.saveToFile
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
@@ -28,10 +26,13 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
|
||||
project.plugins.apply("org.jetbrains.kotlin.jvm")
|
||||
project.plugins.apply("org.jetbrains.kotlin.plugin.compose")
|
||||
|
||||
// TODO: Add to tests
|
||||
project.dependencies.add("implementation", "org.processing:core:4.4.0")
|
||||
// TODO: Add tests
|
||||
project.dependencies.add("implementation", project.fileTree("src").apply { include("**/code/*.jar") })
|
||||
|
||||
// Base JOGL and Gluegen dependencies
|
||||
// TODO: Add only if user is compiling for P2D or P3D
|
||||
project.dependencies.add("runtimeOnly", "org.jogamp.jogl:jogl-all-main:2.5.0")
|
||||
project.dependencies.add("runtimeOnly", "org.jogamp.gluegen:gluegen-rt-main:2.5.0")
|
||||
|
||||
@@ -65,11 +66,8 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
|
||||
application.nativeDistributions.modules("java.management")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Also only do within Processing
|
||||
project.tasks.named("wrapper").configure {
|
||||
it.enabled = false
|
||||
}
|
||||
project.tasks.findByName("wrapper")?.enabled = false
|
||||
|
||||
project.tasks.create("sketch").apply {
|
||||
group = "processing"
|
||||
@@ -116,7 +114,6 @@ class ProcessingPlugin @Inject constructor(private val objectFactory: ObjectFact
|
||||
sourceSet.java.srcDir(outputDirectory)
|
||||
|
||||
// TODO: Support multiple sketches?
|
||||
// TODO: Preprocess PDE files in this step so we can add the library dependencies
|
||||
|
||||
val taskName = sourceSet.getTaskName("preprocess", "PDE")
|
||||
project.tasks.register(taskName, ProcessingTask::class.java) { task ->
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.io.UncheckedIOException
|
||||
import java.util.concurrent.Callable
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class ProcessingTask() : SourceTask() {
|
||||
abstract class ProcessingTask : SourceTask() {
|
||||
@get:OutputDirectory
|
||||
var outputDirectory: File? = null
|
||||
|
||||
@@ -62,6 +62,10 @@ abstract class ProcessingTask() : SourceTask() {
|
||||
|
||||
// TODO: Only import the libraries that are actually used
|
||||
val importStatement = meta.importStatements
|
||||
|
||||
// for (import in importStatement) {
|
||||
// project.dependencies.add("implementation", import)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
48
java/gradle/src/test/kotlin/ProcessingPluginTest.kt
Normal file
48
java/gradle/src/test/kotlin/ProcessingPluginTest.kt
Normal file
@@ -0,0 +1,48 @@
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import org.gradle.testkit.runner.GradleRunner
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class ProcessingPluginTest{
|
||||
@Test
|
||||
fun testPluginAddsSketchTask(){
|
||||
val project = ProjectBuilder.builder().build()
|
||||
project.pluginManager.apply("processing.java.gradle")
|
||||
|
||||
assert(project.tasks.getByName("sketch") is Task)
|
||||
}
|
||||
@JvmField
|
||||
@Rule
|
||||
val folder: TemporaryFolder = TemporaryFolder()
|
||||
|
||||
@Test
|
||||
fun testPluginOutcome() {
|
||||
|
||||
val buildFile = folder.newFile("build.gradle.kts")
|
||||
buildFile.writeText("""
|
||||
plugins{
|
||||
id("processing.java.gradle")
|
||||
}
|
||||
""".trimIndent())
|
||||
|
||||
val sketchFile = folder.newFile("sketch.pde")
|
||||
sketchFile.writeText("""
|
||||
void setup(){
|
||||
size(100, 100);
|
||||
}
|
||||
void draw(){
|
||||
background(0);
|
||||
}
|
||||
""".trimIndent())
|
||||
|
||||
val result = GradleRunner.create()
|
||||
.withProjectDir(folder.root)
|
||||
.withArguments("build")
|
||||
.withPluginClasspath()
|
||||
.build()
|
||||
|
||||
assert(folder.root.resolve(".processing/generated/pde/main").exists())
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,4 @@ include(
|
||||
"java:libraries:pdf",
|
||||
"java:libraries:serial",
|
||||
"java:libraries:svg",
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user