Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
129 lines (110 loc) · 4.2 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
129 lines (110 loc) · 4.2 KB
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
import java.io.PrintWriter
import java.io.StringWriter
import java.util.jar.JarFile
import java.util.spi.ToolProvider
plugins {
java
`maven-publish`
}
group = "com.github.ItsHarshXD"
version = "1.8.0"
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withJavadocJar()
withSourcesJar()
}
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven("https://jitpack.io")
}
val baselineApi by configurations.creating
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.9-R0.1-SNAPSHOT")
compileOnly("org.projectlombok:lombok:1.18.30")
annotationProcessor("org.projectlombok:lombok:1.18.30")
compileOnly("org.jetbrains:annotations:24.1.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.11.4")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.11.4")
testImplementation("io.papermc.paper:paper-api:1.21.9-R0.1-SNAPSHOT")
baselineApi("com.github.ItsHarshXD:ZentrixAPI:1.7.0")
}
tasks.test {
useJUnitPlatform()
}
tasks.register("verifyBinaryCompatibility") {
group = "verification"
description = "Checks that every public baseline API declaration still exists in this build."
dependsOn(tasks.jar)
doLast {
val oldJar = baselineApi.singleFile
val newJar = tasks.jar.get().archiveFile.get().asFile
val javap = ToolProvider.findFirst("javap").orElseThrow()
val support = configurations.compileClasspath.get().asPath
fun declarations(jar: File, className: String): Set<String> {
val output = StringWriter()
val exit = javap.run(PrintWriter(output), PrintWriter(output),
"-public", "-classpath", jar.absolutePath + File.pathSeparator + support, className)
check(exit == 0) { "javap failed for $className: $output" }
return output.toString().lineSequence().map(String::trim)
.filter { it.endsWith(";") && (it.startsWith("public ") || it.startsWith("protected ")) }
.map { it.replace(" abstract ", " ").replace(" default ", " ") }
.toSet()
}
val failures = mutableListOf<String>()
JarFile(oldJar).use { baseline ->
baseline.entries().asSequence()
.filter { !it.isDirectory && it.name.endsWith(".class") && it.name != "module-info.class" }
.map { it.name.removeSuffix(".class").replace('/', '.') }
.forEach { className ->
val current = declarations(newJar, className)
declarations(oldJar, className).filterNot(current::contains)
.forEach { failures += "$className: $it" }
}
}
check(failures.isEmpty()) { "Binary-incompatible API declarations:\n" + failures.joinToString("\n") }
}
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
tasks.javadoc {
(options as StandardJavadocDocletOptions).apply {
encoding = "UTF-8"
addStringOption("Xdoclint:none", "-quiet")
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
groupId = "com.github.ItsHarshXD"
artifactId = "ZentrixAPI"
from(components["java"])
pom {
name.set("ZentrixAPI")
description.set("Developer API for creating Zentrix addons")
url.set("https://github.com/ItsHarshXD/ZentrixAPI")
licenses {
license {
name.set("All Rights Reserved")
}
}
developers {
developer {
id.set("itsharshxd")
name.set("ItsHarshXD")
}
}
scm {
connection.set("scm:git:github.com/ItsHarshXD/ZentrixAPI.git")
developerConnection.set("scm:git:ssh://github.com/ItsHarshXD/ZentrixAPI.git")
url.set("https://github.com/ItsHarshXD/ZentrixAPI")
}
}
}
}
}