-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbuild.gradle.kts
214 lines (183 loc) · 5.71 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import io.github.z4kn4fein.semver.toVersion
import java.nio.file.Files
plugins {
`java-library`
`maven-publish`
alias(libs.plugins.shadow)
alias(libs.plugins.userdev) apply false
}
val name = "Insights"
group = "dev.frankheijden.insights"
val dependencyDir = "$group.dependencies"
version = "6.19.3"
subprojects {
apply(plugin = "java")
apply(plugin = "checkstyle")
apply(plugin = "com.gradleup.shadow")
version = rootProject.version
val groupParts = project.name.split('-').drop(1)
val nms = groupParts.isNotEmpty() && groupParts.first() == "NMS"
val nmsImpl = nms && groupParts.last() != "Core"
if (nmsImpl) {
apply(plugin = "io.papermc.paperweight.userdev")
}
group = if (groupParts.isEmpty()) {
rootProject.group
} else {
rootProject.group.toString() + groupParts.joinToString(".", ".") {
if (it.startsWith("v")) {
it
} else {
it.lowercase()
}
}
}
repositories {
mavenCentral()
maven("https://jitpack.io")
maven("https://repo.codemc.io/repository/maven-public")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://libraries.minecraft.net")
}
val libs = rootProject.libs
dependencies {
compileOnly(libs.paperApi)
implementation(libs.paperLib)
implementation(libs.bStatsBukkit)
implementation(libs.adventureApi)
implementation(libs.adventureMiniMessage)
implementation(libs.adventurePlatformBukkit)
if (!nms || nmsImpl) {
compileOnly(project(":Insights-NMS-Core"))
}
testImplementation(libs.paperApi)
testImplementation(libs.assertj)
testImplementation(libs.mockitoCore)
testImplementation(libs.jupiterApi)
testImplementation(libs.jupiterParams)
testImplementation(libs.jupiterEngine)
}
tasks {
build {
dependsOn("shadowJar", "checkstyleMain", "checkstyleTest", "test")
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.isDeprecation = true
sourceCompatibility = JavaVersion.VERSION_21.majorVersion
targetCompatibility = JavaVersion.VERSION_21.majorVersion
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
test {
useJUnitPlatform()
}
}
tasks.withType<Checkstyle>().configureEach {
configFile = file("$rootDir/config/checkstyle/checkstyle.xml")
ignoreFailures = false
maxErrors = 0
maxWarnings = 0
}
tasks.withType<ShadowJar> {
relocate("dev.frankheijden.minecraftreflection", "$dependencyDir.minecraftreflection")
relocate("io.papermc.lib", "$dependencyDir.paperlib")
relocate("org.bstats", "$dependencyDir.bstats")
relocate("net.kyori.adventure", "$dependencyDir.adventure")
relocate("net.kyori.examination", "$dependencyDir.examination")
relocate("net.kyori.option", "$dependencyDir.option")
if (nmsImpl) {
relocate(project.group.toString().replaceAfterLast('.', "impl"), project.group.toString())
}
}
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
implementation(project(":Insights-API", "shadow"))
implementation(project(":Insights", "shadow"))
Files
.list(rootProject.projectDir.toPath().resolve("Insights-NMS"))
.filter { !it.fileName.toString().startsWith(".") }
.forEach {
val configuration = if (it.fileName.toString() == "Core") "shadow" else "reobf"
implementation(project(":Insights-NMS-${it.fileName}", configuration))
}
}
tasks {
clean {
dependsOn("cleanJars")
}
build {
dependsOn("shadowJar")
finalizedBy("copyJars")
}
}
tasks.register("cleanJars") {
delete(file("jars"))
}
tasks.register<Copy>("copyJars") {
from(tasks.findByPath("shadowJar")!!) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
into(file("jars"))
rename("(.+)Parent(.+)-all(.+)", "$1$2$3")
}
buildscript {
dependencies {
classpath("io.github.z4kn4fein:semver:2.0.0")
}
}
val artifactFile: File = tasks.shadowJar.get().archiveFile.get().asFile
val artifact: PublishArtifact = artifacts.add("archives", artifactFile) {
type = "jar"
name = "Insights"
group = rootProject.group
version = rootProject.version
classifier = ""
builtBy("shadowJar")
}
fun Project.isRelease(): Boolean {
return version.toString().toVersion().preRelease == null
}
task("printIsRelease") {
doLast {
println(isRelease())
}
}
task("printVersion") {
doLast {
println(version.toString())
}
}
publishing {
repositories {
maven {
name = "fvdh"
url = if (version.toString().toVersion().preRelease == null) {
uri("https://repo.fvdh.dev/releases")
} else {
uri("https://repo.fvdh.dev/snapshots")
}
credentials {
username = System.getenv("FVDH_USERNAME")
password = System.getenv("FVDH_TOKEN")
}
}
}
publications {
create<MavenPublication>("Insights") {
artifact(artifact)
artifactId = "Insights"
}
}
}