-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.gradle.kts
165 lines (143 loc) · 5.58 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
plugins {
`java-library`
`maven-publish`
}
// = = =
val pluginName = "PlayerTimeTracker"
val paperApiName = "1.21.1-R0.1-SNAPSHOT"
// Version used for distribution. Different from maven repo
group = "cat.nyaa"
version = "0.10-alpha.3"
java {
// Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 8 installed for example.
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
repositories {
mavenCentral()
maven { url = uri("https://papermc.io/repo/repository/maven-public/") } //paper
maven { url = uri("https://libraries.minecraft.net") } // mojang
// maven { url = uri("https://repo.essentialsx.net/releases/") } // essentials
maven { url = uri("https://repo.essentialsx.net/snapshots/") } // essentials
maven { url = uri("https://ci.nyaacat.com/maven/") } // nyaacat
// maven {
// url = uri("https://maven.pkg.github.com/NyaaCat/NyaaCore")
// credentials {
// username = System.getenv("GITHUB_MAVEN_USER") ?: project.findProperty("gpr.user").toString()
// password = System.getenv("GITHUB_MAVEN_TOKEN") ?: project.findProperty("gpr.key").toString()
// }
// } // NyaaCore
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") } // placeholderapi
}
dependencies {
compileOnly("io.papermc.paper:paper-api:$paperApiName")
compileOnly("org.jetbrains:annotations:24.1.0")
// soft dep
compileOnly("net.essentialsx:EssentialsX:2.21.0-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly("com.udojava:EvalEx:2.7")
compileOnly("org.xerial:sqlite-jdbc:3.46.0.0")
compileOnly("com.zaxxer:HikariCP:5.1.0")
// other nyaa plugins
compileOnly("cat.nyaa:nyaacore:9.4")
compileOnly("cat.nyaa:ecore:0.3.4") // optional
// test
testImplementation(platform("org.junit:junit-bom:5.10.3"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.slf4j:slf4j-simple:2.0.9")
testImplementation("com.github.seeseemelk:MockBukkit-v1.21:3.107.0")
testImplementation("org.xerial:sqlite-jdbc:3.46.0.0")
testImplementation("com.zaxxer:HikariCP:5.1.0")
testImplementation("cat.nyaa:nyaacore:9.4")
testImplementation("cat.nyaa:ecore:0.3.4")
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(getComponents()["java"])
artifactId = pluginName.lowercase()
groupId = group.toString()
version = project.version.toString()
}
}
repositories {
maven {
name = "GithubPackage"
url = uri(System.getenv("MAVEN_PUBLISH_URL") ?: layout.buildDirectory.dir("repo"))
val mavenUsername = System.getenv("MAVEN_PUBLISH_USERNAME")
val mavenPassword = System.getenv("MAVEN_PUBLISH_PASSWORD")
if(mavenUsername != null && mavenPassword != null) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
maven {
name = "NyaaCatCILocal"
//local maven repository
url = uri("file://${System.getenv("MAVEN_DIR")}")
}
}
}
// Custom tasks for publishing to specific repositories
tasks.register("publishToGithubPackage") {
dependsOn("publishMavenJavaPublicationToGithubPackageRepository")
// auto generated task: publish<PublicationName>PublicationTo<RepositoryName>Repository
}
tasks.register("publishToNyaaCatCILocal") {
dependsOn("publishMavenJavaPublicationToNyaaCatCILocalRepository")
}
tasks {
withType<ProcessResources> {
val newProperties = project.properties.toMutableMap()
newProperties["api_version"] = getMcVersion(paperApiName, 2)
filesMatching("plugin.yml") {
expand(newProperties)
}
}
compileJava {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
// See https://openjdk.java.net/jeps/247 for more information.
options.release.set(21)
}
javadoc {
with((options as StandardJavadocDocletOptions)) {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
links("https://docs.oracle.com/en/java/javase/21/docs/api/")
links("https://guava.dev/releases/21.0/api/docs/")
links("https://ci.md-5.net/job/BungeeCord/ws/chat/target/apidocs/")
links("https://jd.papermc.io/paper/1.21/")
options.locale = "en_US"
options.encoding = "UTF-8"
(options as StandardJavadocDocletOptions).addBooleanOption(
"keywords",
true
)
(options as StandardJavadocDocletOptions).addStringOption(
"Xdoclint:none",
"-quiet"
)
(options as StandardJavadocDocletOptions).addBooleanOption(
"html5",
true
)
options.windowTitle = "$pluginName Javadoc"
}
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
}
private fun getMcVersion(apiNameString: String, parts: Int = -1): String {
val mcVersion = apiNameString.split('-')[0]
val splitInput = mcVersion.split('.')
return if (parts > 0 && parts < splitInput.size) {
splitInput.take(parts).joinToString(".")
} else {
mcVersion
}
}