From 20425fd0e58f66b55c3e15449fe45d50be104354 Mon Sep 17 00:00:00 2001 From: "[Nia Perez]" Date: Mon, 28 Jul 2025 14:30:12 -0400 Subject: [PATCH] Worked on migration of the dxf library from Ant to Gradle Signed-off-by: [Nia Perez] Co-authored-by: Amante' Woodley Co-authored-by: Kayla Bobo Co-authored-by: Silas Morgan --- java/build.gradle.kts | 40 ++++++++++++++++++++++------- java/libraries/dxf/build.gradle.kts | 40 ++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 10 deletions(-) diff --git a/java/build.gradle.kts b/java/build.gradle.kts index 0f8e052780..22efe584c3 100644 --- a/java/build.gradle.kts +++ b/java/build.gradle.kts @@ -1,11 +1,11 @@ plugins { - id("java") + java } repositories{ mavenCentral() google() - maven { url = uri("https://jogamp.org/deployment/maven") } + maven("https://jogamp.org/deployment/maven") } sourceSets{ @@ -47,13 +47,15 @@ tasks.compileJava{ // LEGACY TASKS // Most of these are shims to be compatible with the old build system // They should be removed in the future, as we work towards making things more Gradle-native -tasks.register("extraResources"){ - dependsOn(":java:copyCore") +val javaMode = { path : String -> layout.buildDirectory.dir("resources-bundled/common/modes/java/$path") } + +val bundle = tasks.register("extraResources"){ + dependsOn("copyCore") from(".") include("keywords.txt") include("theme/**/*") include("application/**/*") - into( layout.buildDirectory.dir("resources-bundled/common/modes/java")) + into(javaMode("")) } tasks.register("copyCore"){ val coreProject = project(":core") @@ -65,8 +67,8 @@ tasks.register("copyCore"){ into(coreProject.layout.projectDirectory.dir("library")) } -val libraries = arrayOf("dxf","io","net","pdf","serial","svg") -libraries.forEach { library -> +val legacyLibraries = arrayOf("dxf","io","net","serial","svg") +legacyLibraries.forEach { library -> tasks.register("library-$library-extraResources"){ val build = project(":java:libraries:$library").tasks.named("build") build.configure { @@ -77,10 +79,30 @@ libraries.forEach { library -> include("*.properties") include("library/**/*") include("examples/**/*") - into( layout.buildDirectory.dir("resources-bundled/common/modes/java/libraries/$library")) + into( javaMode("/libraries/$library")) + } + bundle.configure { + dependsOn("library-$library-extraResources") + } +} + +val libraries = arrayOf("dxf") +libraries.forEach { library -> + val name = "create-$library-library" + tasks.register(name) { + group = "libraries" + val project = project(":java:libraries:$library") + val libraryTask = project.tasks.named("createLibrary") + dependsOn(libraryTask) + + from(project.layout.buildDirectory.dir("library")) + into(javaMode("/libraries/$library")) + } + bundle.configure { + dependsOn(name) } - tasks.named("extraResources"){ dependsOn("library-$library-extraResources") } } + tasks.jar { dependsOn("extraResources") } tasks.processResources{ finalizedBy("extraResources") } tasks.compileTestJava{ finalizedBy("extraResources") } diff --git a/java/libraries/dxf/build.gradle.kts b/java/libraries/dxf/build.gradle.kts index a176f03df7..cf4e3f5074 100644 --- a/java/libraries/dxf/build.gradle.kts +++ b/java/libraries/dxf/build.gradle.kts @@ -1 +1,39 @@ -ant.importBuild("build.xml") \ No newline at end of file +plugins{ + java +} + +sourceSets { + main { + java { + srcDirs("src") + } + } +} +repositories{ + mavenCentral() + maven("https://jogamp.org/deployment/maven/") +} + +dependencies{ + compileOnly(project(":core")) + + implementation("com.lowagie:itext:2.1.7") +} + +tasks.register("createLibrary"){ + dependsOn("jar") + into(layout.buildDirectory.dir("library")) + + from(layout.projectDirectory){ + include ("library.properties") + include("examples/**") + } + + from(configurations.runtimeClasspath){ + into("library") + } + + from(tasks.jar) { + into("library") + } +} \ No newline at end of file