-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
212 lines (178 loc) · 6.49 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
import java.text.SimpleDateFormat
import java.util.Date
plugins {
id("java-library")
id("maven-publish")
id("net.kyori.blossom") version "1.3.1"
id("com.gradleup.shadow") version "8.3.0"
}
group = this.compileGroup()
version = this.compileVersion()
val properties = mapOf(
"pluginVersion" to version,
"pluginName" to project.properties["plugin_name"],
"pluginId" to project.properties["plugin_id"]
)
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://lib.alpn.cloud/alpine-public/")
maven("https://repo.panda-lang.org/releases")
}
dependencies {
compileOnly("org.apache.logging.log4j:log4j-core:2.0-beta9")
compileOnly("org.spigotmc:spigot-api:${project.properties["spigot_version"]}")
depend(this, "org.jetbrains:annotations:24.1.0", true)
depend(this, "dev.tomwmth:configlib-spigot:4.5.0")
depend(this, "org.msgpack:msgpack-core:0.9.8")
val liteCommands = "3.4.2"
depend(this, "dev.rollczi:litecommands-bukkit:${liteCommands}")
depend(this, "dev.rollczi:litecommands-adventure-platform:${liteCommands}")
val adventure = "4.17.0"
depend(this, "net.kyori:adventure-platform-bukkit:4.3.4")
depend(this, "net.kyori:adventure-api:${adventure}")
depend(this, "net.kyori:adventure-text-minimessage:${adventure}")
depend(this, "net.kyori:adventure-text-serializer-legacy:${adventure}")
val lombok = "org.projectlombok:lombok:1.18.34"
compileOnly(lombok)
annotationProcessor(lombok)
}
java {
withSourcesJar()
withJavadocJar()
}
blossom {
properties.forEach {
replaceToken("\${${it.key}}", it.value)
}
}
base {
archivesName.set(project.properties["plugin_name"] as String)
}
tasks.jar {
// Add exclusions
exclude("META-INF/versions/")
exclude("META-INF/maven/")
// Fill out manifest
manifest {
attributes(
"Manifest-Version" to "1.0",
"Created-By" to "Gradle",
"Built-JDK" to "${System.getProperty("java.version")} (${System.getProperty("java.vendor")})",
"Built-By" to System.getProperty("user.name"),
"Built-Date" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()),
"Name" to project.group.toString().replace(".", "/"),
"Implementation-Title" to project.properties["plugin_name"],
"Implementation-Version" to project.version,
"Implementation-Vendor" to "Crystal Development, LLC.",
"Specification-Title" to project.properties["plugin_name"],
"Specification-Version" to project.version,
"Specification-Vendor" to "Crystal Development, LLC.",
)
}
// Add license
from("LICENSE") {
into("META-INF/")
}
}
tasks.shadowJar {
dependsOn("jar")
outputs.upToDateWhen { false }
// Relocate dependencies
val root = "com.alpineclient.dependencies"
relocate("de.exlll", "$root.de.exlll")
relocate("dev.rollczi", "$root.dev.rollczi")
relocate("net.jodah", "$root.net.jodah")
relocate("net.kyori", "$root.net.kyori")
relocate("org.intellij", "$root.org.intellij")
relocate("org.jetbrains", "$root.org.jetbrains")
relocate("org.msgpack", "$root.org.msgpack")
relocate("org.snakeyaml", "$root.org.snakeyaml")
relocate("panda", "$root.panda")
// Add shaded dependencies
configurations.clear()
configurations.add(project.configurations.getByName("shadow"))
// Set classifier
archiveClassifier.set("shaded")
}
tasks.build {
dependsOn(tasks.shadowJar)
}
tasks.processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
inputs.properties(properties)
filesMatching("plugin.yml") {
expand(properties)
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
publishing {
publications {
create<MavenPublication>("maven") {
artifact(tasks["jar"])
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
pom {
name.set(project.properties["plugin_name"] as String)
description.set("Plugin implementation of the Alpine Client API.")
url.set("https://alpineclient.com/")
groupId = project.properties["maven_group"] as String
artifactId = "api-plugin"
packaging = "jar"
licenses {
license {
name = "Mozilla Public License, version 2.0"
url = "https://www.mozilla.org/en-US/MPL/2.0/"
}
}
withXml {
val dependenciesNode = asNode().appendNode("dependencies")
configurations["api"].allDependencies.forEach {
val dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.group)
dependencyNode.appendNode("artifactId", it.name)
dependencyNode.appendNode("version", it.version)
dependencyNode.appendNode("scope", "compile")
}
}
}
}
}
repositories {
maven {
name = "AlpnCloud"
url = uri("https://lib.alpn.cloud/alpine-public")
credentials {
username = System.getenv("ALPINE_MAVEN_NAME")
password = System.getenv("ALPINE_MAVEN_SECRET")
}
}
}
}
tasks.javadoc {
options {
this as StandardJavadocDocletOptions
stylesheetFile = File(projectDir, "/dracula-stylesheet.css")
}
setDestinationDir(File(projectDir, "/docs/"))
include(project.group.toString().replace(".", "/") + "/api/**/*.java")
}
fun compileGroup(): String {
return "${project.properties["maven_group"]}.${project.properties["maven_artifact"]}"
}
fun compileVersion(): String {
val major = project.properties["version_major"]
val minor = project.properties["version_minor"]
val patch = project.properties["version_patch"]
val preRelease = project.properties["version_pre_release"]
return "${major}.${minor}.${patch}${if (preRelease == "none") "" else "-${preRelease}"}"
}
fun depend(scope: DependencyHandlerScope, dependency: String, api: Boolean = false) {
scope.implementation(dependency)
scope.shadow(dependency)
if (api)
scope.api(dependency)
}