Skip to content

Commit 275d789

Browse files
authored
Merge pull request #1189 from Stefterv/fix-pdf-library
Migration of the `pdf` library to Gradle
2 parents 11ba3b4 + faf5997 commit 275d789

File tree

2 files changed

+70
-10
lines changed

2 files changed

+70
-10
lines changed

java/build.gradle.kts

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
plugins {
2-
id("java")
2+
java
33
}
44

55
repositories{
66
mavenCentral()
77
google()
8-
maven { url = uri("https://jogamp.org/deployment/maven") }
8+
maven("https://jogamp.org/deployment/maven")
99
}
1010

1111
sourceSets{
@@ -48,13 +48,15 @@ tasks.compileJava{
4848
// LEGACY TASKS
4949
// Most of these are shims to be compatible with the old build system
5050
// They should be removed in the future, as we work towards making things more Gradle-native
51-
tasks.register<Copy>("extraResources"){
52-
dependsOn(":java:copyCore")
51+
val javaMode = { path : String -> layout.buildDirectory.dir("resources-bundled/common/modes/java/$path") }
52+
53+
val bundle = tasks.register<Copy>("extraResources"){
54+
dependsOn("copyCore")
5355
from(".")
5456
include("keywords.txt")
5557
include("theme/**/*")
5658
include("application/**/*")
57-
into( layout.buildDirectory.dir("resources-bundled/common/modes/java"))
59+
into(javaMode(""))
5860
}
5961
tasks.register<Copy>("copyCore"){
6062
val coreProject = project(":core")
@@ -66,8 +68,8 @@ tasks.register<Copy>("copyCore"){
6668
into(coreProject.layout.projectDirectory.dir("library"))
6769
}
6870

69-
val libraries = arrayOf("dxf","io","net","pdf","serial","svg")
70-
libraries.forEach { library ->
71+
val legacyLibraries = arrayOf("dxf","io","net","serial","svg")
72+
legacyLibraries.forEach { library ->
7173
tasks.register<Copy>("library-$library-extraResources"){
7274
val build = project(":java:libraries:$library").tasks.named("build")
7375
build.configure {
@@ -78,10 +80,30 @@ libraries.forEach { library ->
7880
include("*.properties")
7981
include("library/**/*")
8082
include("examples/**/*")
81-
into( layout.buildDirectory.dir("resources-bundled/common/modes/java/libraries/$library"))
83+
into( javaMode("/libraries/$library"))
84+
}
85+
bundle.configure {
86+
dependsOn("library-$library-extraResources")
87+
}
88+
}
89+
90+
val libraries = arrayOf("pdf")
91+
libraries.forEach { library ->
92+
val name = "create-$library-library"
93+
tasks.register<Copy>(name) {
94+
group = "libraries"
95+
val project = project(":java:libraries:$library")
96+
val libraryTask = project.tasks.named("createLibrary")
97+
dependsOn(libraryTask)
98+
99+
from(project.layout.buildDirectory.dir("library"))
100+
into(javaMode("/libraries/$library"))
101+
}
102+
bundle.configure {
103+
dependsOn(name)
82104
}
83-
tasks.named("extraResources"){ dependsOn("library-$library-extraResources") }
84105
}
106+
85107
tasks.jar { dependsOn("extraResources") }
86108
tasks.processResources{ finalizedBy("extraResources") }
87109
tasks.compileTestJava{ finalizedBy("extraResources") }
Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
ant.importBuild("build.xml")
1+
plugins{
2+
java
3+
}
4+
5+
sourceSets {
6+
main {
7+
java {
8+
srcDirs("src")
9+
}
10+
}
11+
}
12+
repositories{
13+
mavenCentral()
14+
maven("https://jogamp.org/deployment/maven/")
15+
}
16+
17+
dependencies{
18+
compileOnly(project(":core"))
19+
20+
implementation("com.lowagie:itext:2.1.7")
21+
}
22+
23+
tasks.register<Copy>("createLibrary"){
24+
dependsOn("jar")
25+
into(layout.buildDirectory.dir("library"))
26+
27+
from(layout.projectDirectory){
28+
include ("library.properties")
29+
include("examples/**")
30+
}
31+
32+
from(configurations.runtimeClasspath){
33+
into("library")
34+
}
35+
36+
from(tasks.jar) {
37+
into("library")
38+
}
39+
}

0 commit comments

Comments
 (0)