Skip to content

Commit e1bb764

Browse files
Migrate DXF library to Gradle (processing#981)
1 parent 6af4b22 commit e1bb764

File tree

4 files changed

+33
-82
lines changed

4 files changed

+33
-82
lines changed

java/build.gradle.kts

+17-77
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,30 @@
11
plugins {
2-
id("java")
2+
java
33
}
44

5-
repositories{
6-
mavenCentral()
7-
google()
8-
maven { url = uri("https://jogamp.org/deployment/maven") }
9-
}
10-
11-
sourceSets{
12-
main{
13-
java{
14-
srcDirs("src")
15-
exclude("processing/mode/java/preproc/**")
16-
}
17-
}
18-
test{
19-
java{
20-
srcDirs("test")
21-
}
5+
java {
6+
toolchain {
7+
languageVersion.set(JavaLanguageVersion.of(17))
228
}
239
}
2410

25-
dependencies{
26-
implementation(project(":app"))
27-
implementation(project(":core"))
28-
implementation(project(":java:preprocessor"))
29-
30-
implementation(libs.eclipseJDT)
31-
implementation(libs.eclipseJDTCompiler)
32-
implementation(libs.classpathExplorer)
33-
implementation(libs.netbeansSwing)
34-
implementation(libs.ant)
35-
implementation(libs.lsp4j)
36-
implementation(libs.jsoup)
37-
implementation(libs.antlr)
11+
val coreJar = file("../../../core/library/core.jar")
3812

39-
testImplementation(libs.junit)
40-
testImplementation(libs.mockito)
13+
dependencies {
14+
implementation(files(coreJar))
4115
}
4216

43-
tasks.compileJava{
44-
options.encoding = "UTF-8"
45-
}
46-
47-
// LEGACY TASKS
48-
// Most of these are shims to be compatible with the old build system
49-
// They should be removed in the future, as we work towards making things more Gradle-native
50-
tasks.register<Copy>("extraResources"){
51-
dependsOn(":java:copyCore")
52-
from(".")
53-
include("keywords.txt")
54-
include("theme/**/*")
55-
include("application/**/*")
56-
into( layout.buildDirectory.dir("resources-bundled/common/modes/java"))
57-
}
58-
tasks.register<Copy>("copyCore"){
59-
val coreProject = project(":core")
60-
dependsOn(coreProject.tasks.jar)
61-
from(coreProject.tasks.jar) {
62-
include("core*.jar")
63-
}
64-
rename("core.+\\.jar", "core.jar")
65-
into(coreProject.layout.projectDirectory.dir("library"))
66-
}
67-
68-
val libraries = arrayOf("dxf","io","net","pdf","serial","svg")
69-
libraries.forEach { library ->
70-
tasks.register<Copy>("library-$library-extraResources"){
71-
val build = project(":java:libraries:$library").tasks.named("build")
72-
build.configure {
73-
dependsOn(":java:copyCore")
17+
tasks.register("checkCore") {
18+
doFirst {
19+
if (!coreJar.exists()) {
20+
throw GradleException("Missing core.jar at $coreJar. Please build the core module first.")
7421
}
75-
dependsOn(build)
76-
from("libraries/$library")
77-
include("*.properties")
78-
include("library/**/*")
79-
include("examples/**/*")
80-
into( layout.buildDirectory.dir("resources-bundled/common/modes/java/libraries/$library"))
8122
}
82-
tasks.named("extraResources"){ dependsOn("library-$library-extraResources") }
8323
}
84-
tasks.jar { dependsOn("extraResources") }
85-
tasks.processResources{ finalizedBy("extraResources") }
86-
tasks.compileTestJava{ finalizedBy("extraResources") }
8724

88-
tasks.test {
89-
useJUnit()
90-
}
25+
tasks.register<Jar>("dxfJar") {
26+
dependsOn("checkCore", "classes")
27+
archiveBaseName.set("dxf")
28+
destinationDirectory.set(file("library"))
29+
from(sourceSets.main.get().output)
30+
}

java/libraries/dxf/build.gradle.kts

-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,3 @@ tasks.register<Jar>("dxfJar") {
3030
from(sourceSets.main.get().output)
3131
}
3232

33-
tasks.register("clean") {
34-
doLast {
35-
delete("build", "library/dxf.jar")
36-
}
37-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest-Version: 1.0
2+

settings.gradle.kts

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
pluginManagement {
2+
plugins {
3+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
4+
}
5+
repositories {
6+
gradlePluginPortal()
7+
}
8+
}
9+
10+
plugins {
11+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
12+
}
13+
14+
rootProject.name = "processing"
115
rootProject.name = "processing"
216
include(
317
"core",

0 commit comments

Comments
 (0)