forked from plantuml/plantuml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
203 lines (182 loc) · 5.6 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// permits to start the build setting the javac release parameter, no parameter means build for java8:
// gradle clean build -x javaDoc -PjavacRelease=8
// gradle clean build -x javaDoc -PjavacRelease=17
// also supported is to build first, with java17, then switch the java version, and run the test with java8:
// gradle clean build -x javaDoc -x test
// gradle test
println("Running build.gradle.kts")
println(project.version)
val javacRelease = (project.findProperty("javacRelease") ?: "8") as String
plugins {
java
`maven-publish`
signing
eclipse
// id("com.adarshr.test-logger") version "3.2.0"
}
group = "net.sourceforge.plantuml"
description = "PlantUML"
java {
withSourcesJar()
withJavadocJar()
registerFeature("pdf") {
usingSourceSet(sourceSets["main"])
}
}
dependencies {
compileOnly("org.apache.ant:ant:1.10.14")
testImplementation("io.github.glytching:junit-extensions:2.6.0")
testImplementation("org.assertj:assertj-core:3.26.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testImplementation("org.xmlunit:xmlunit-core:2.10.+")
if (JavaVersion.current().isJava8) {
testImplementation("org.mockito:mockito-core:4.+")
testImplementation("org.mockito:mockito-junit-jupiter:4.+")
} else {
testImplementation("org.mockito:mockito-core:5.+")
testImplementation("org.mockito:mockito-junit-jupiter:5.+")
}
implementation("org.scilab.forge:jlatexmath:1.0.7")
implementation("org.eclipse.elk:org.eclipse.elk.core:0.9.1")
implementation("org.eclipse.elk:org.eclipse.elk.alg.layered:0.9.1")
implementation("org.eclipse.elk:org.eclipse.elk.alg.mrtree:0.9.1")
}
repositories {
mavenLocal()
mavenCentral()
}
sourceSets {
main {
java {
srcDirs("src")
}
resources {
srcDirs("src")
include("**/graphviz.dat")
include("**/*.png")
include("**/*.svg")
include("**/*.txt")
}
}
test {
java {
srcDirs("test")
}
resources {
srcDirs(".")
include("skin/**/*.skin")
include("themes/**/*.puml")
}
}
}
tasks.compileJava {
if (JavaVersion.current().isJava8) {
java.targetCompatibility = JavaVersion.VERSION_1_8
} else {
options.release.set(Integer.parseInt(javacRelease))
}
}
tasks.withType<Jar>().configureEach {
manifest {
attributes["Main-Class"] = "net.sourceforge.plantuml.Run"
attributes["Implementation-Version"] = archiveVersion
attributes["Build-Jdk-Spec"] = System.getProperty("java.specification.version")
from("manifest.txt")
}
from("skin") { into("skin") }
from("stdlib") { into("stdlib") }
from("svg") { into("svg") }
from("themes") { into("themes") }
// Add dependencies to the JAR
val runtimeClasspath = configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) }
from(runtimeClasspath) {
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA") // Avoid conflict on signature
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
pom {
name.set("PlantUML")
description.set("PlantUML is a component that allows to quickly write diagrams from text.")
groupId = project.group as String
artifactId = project.name
version = project.version as String
url.set("https://plantuml.com/")
licenses {
license {
name.set("The GNU General Public License")
url.set("http://www.gnu.org/licenses/gpl.txt")
}
}
developers {
developer {
id.set("arnaud.roques")
name.set("Arnaud Roques")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com:plantuml/plantuml.git")
developerConnection.set("scm:git:ssh://[email protected]:plantuml/plantuml.git")
url.set("https://github.com/plantuml/plantuml")
}
}
}
repositories {
maven {
name = "OSSRH"
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
tasks.withType<Javadoc>().configureEach {
options {
this as StandardJavadocDocletOptions
addBooleanOption("Xdoclint:none", true)
addStringOption("Xmaxwarns", "1")
encoding = "UTF-8"
isUse = true
}
}
tasks.test {
doFirst {
println("Java Home:" + System.getProperty("java.home"));
println("Java Version: " + System.getProperty("java.version"));
}
useJUnitPlatform()
testLogging.showStandardStreams = true
}
val pdfJar by tasks.registering(Jar::class) {
group = "build" // OR for example, "build"
description = "Assembles a jar containing dependencies to create PDFs."
manifest.attributes["Main-Class"] = "net.sourceforge.plantuml.Run"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
val dependencies = configurations.runtimeClasspath.get().map(::zipTree)
from(dependencies)
with(tasks.jar.get())
archiveAppendix.set("pdf")
}
signing {
if (hasProperty("signing.gnupg.keyName") && hasProperty("signing.gnupg.passphrase")) {
useGpgCmd()
} else if (hasProperty("signingKey") && hasProperty("signingPassword")) {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
}
if (hasProperty("signing.gnupg.passphrase") || hasProperty("signingPassword")) {
sign(publishing.publications["maven"])
sign(closureOf<SignOperation> { sign(pdfJar.get()) })
}
}