-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathbuild.gradle.kts
224 lines (190 loc) · 6.74 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
* This file is part of npc-lib, licensed under the MIT License (MIT).
*
* Copyright (c) 2022-2023 Julian M., Pasqual K. and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import com.diffplug.gradle.spotless.SpotlessExtension
plugins {
alias(libs.plugins.spotless)
alias(libs.plugins.nexusPublish)
}
defaultTasks("clean", "build")
allprojects {
version = "3.0.0-SNAPSHOT"
group = "io.github.juliarn"
description = "Abstract NPC-Library for Minecraft 1.8+ Servers"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
// more stable replacement for jitpack
maven("https://repository.derklaro.dev/releases/") {
mavenContent {
releasesOnly()
}
}
maven("https://repository.derklaro.dev/snapshots/") {
mavenContent {
snapshotsOnly()
}
}
// packetevents
maven("https://repo.codemc.io/repository/maven-releases/") {
mavenContent {
includeGroup("com.github.retrooper")
}
}
}
}
subprojects {
// apply all plugins only to subprojects
apply(plugin = "signing")
apply(plugin = "checkstyle")
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "com.diffplug.spotless")
dependencies {
"compileOnly"(rootProject.libs.annotations)
}
configurations.all {
// unsure why but every project loves them, and they literally have an import for every letter I type - beware
exclude("org.checkerframework", "checker-qual")
}
tasks.withType<Jar> {
from(rootProject.file("license.txt"))
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.withType<JavaCompile>().configureEach {
// options
options.release.set(8)
options.encoding = "UTF-8"
options.isIncremental = true
// we are aware that those are there, but we only do that if there is no other way we can use - so please keep the terminal clean!
options.compilerArgs = mutableListOf("-Xlint:-deprecation,-unchecked")
}
extensions.configure<JavaPluginExtension> {
disableAutoTargetJvm()
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
tasks.withType<Checkstyle> {
maxErrors = 0
maxWarnings = 0
configFile = rootProject.file("checkstyle.xml")
}
extensions.configure<CheckstyleExtension> {
toolVersion = rootProject.libs.versions.checkstyleTools.get()
}
extensions.configure<SpotlessExtension> {
java {
licenseHeaderFile(rootProject.file("license_header.txt"))
}
}
tasks.withType<Javadoc> {
val options = options as? StandardJavadocDocletOptions ?: return@withType
// options
options.encoding = "UTF-8"
options.memberLevel = JavadocMemberLevel.PRIVATE
options.addStringOption("-html5")
options.addBooleanOption("Xdoclint:-missing", true)
}
tasks.register<org.gradle.jvm.tasks.Jar>("javadocJar") {
archiveClassifier.set("javadoc")
from(tasks.getByName("javadoc"))
}
tasks.register<org.gradle.jvm.tasks.Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(project.the<SourceSetContainer>()["main"].allJava)
}
extensions.configure<PublishingExtension> {
publications.apply {
create("maven", MavenPublication::class.java).apply {
// main output to publish
from(components.getByName("java"))
// additional artifacts
artifact(tasks.getByName("sourcesJar"))
artifact(tasks.getByName("javadocJar"))
pom {
name.set(project.name)
description.set(project.description)
url.set("https://github.com/juliarn/NPC-Lib")
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
scm {
tag.set("HEAD")
url.set("[email protected]:juliarn/NPC-Lib.git")
connection.set("scm:git:[email protected]:juliarn/NPC-Lib.git")
developerConnection.set("scm:git:[email protected]:juliarn/NPC-Lib.git")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/juliarn/NPC-Lib/issues")
}
ciManagement {
system.set("GitHub Actions")
url.set("https://github.com/juliarn/NPC-Lib/actions")
}
developers {
developer {
id.set("derklaro")
email.set("[email protected]")
timezone.set("Europe/Berlin")
name.set("Pasqual Koschmieder")
}
}
withXml {
val repositories = asNode().appendNode("repositories")
project.repositories.forEach {
if (it is MavenArtifactRepository && it.url.toString().startsWith("https://")) {
val repo = repositories.appendNode("repository")
repo.appendNode("id", it.name)
repo.appendNode("url", it.url.toString())
}
}
}
}
}
}
}
tasks.withType<Sign> {
onlyIf {
!rootProject.version.toString().endsWith("-SNAPSHOT")
}
}
extensions.configure<SigningExtension> {
useGpgCmd()
sign(extensions.getByType(PublishingExtension::class.java).publications.getByName("maven"))
}
}
nexusPublishing {
repositories.run {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(project.findProperty("ossrhUsername") as? String ?: "")
password.set(project.findProperty("ossrhPassword") as? String ?: "")
}
}
useStaging.set(!project.version.toString().endsWith("-SNAPSHOT"))
}