Skip to content

Migration of the dxf library from Ant to Gradle #1192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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{
Expand Down Expand Up @@ -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<Copy>("extraResources"){
dependsOn(":java:copyCore")
val javaMode = { path : String -> layout.buildDirectory.dir("resources-bundled/common/modes/java/$path") }

val bundle = tasks.register<Copy>("extraResources"){
dependsOn("copyCore")
from(".")
include("keywords.txt")
include("theme/**/*")
include("application/**/*")
into( layout.buildDirectory.dir("resources-bundled/common/modes/java"))
into(javaMode(""))
}
tasks.register<Copy>("copyCore"){
val coreProject = project(":core")
Expand All @@ -65,8 +67,8 @@ tasks.register<Copy>("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<Copy>("library-$library-extraResources"){
val build = project(":java:libraries:$library").tasks.named("build")
build.configure {
Expand All @@ -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<Copy>(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") }
Expand Down
40 changes: 39 additions & 1 deletion java/libraries/dxf/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
ant.importBuild("build.xml")
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<Copy>("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")
}
}
Loading