-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.gradle.kts
193 lines (159 loc) · 5.21 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
import java.net.URI
plugins {
java
`maven-publish`
signing
// Code formatting
id("com.diffplug.spotless") version "7.0.2"
}
/**
* If true, Sonatype upload credentials have been defined in ~/.gradle/gradle.properties.
*/
val hasSonatypeCredentials = project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")
allprojects {
group = "com.samjakob"
version = "2.0.0"
project.uri("https://github.com/SamJakob/SpiGUI")
apply(plugin = "java")
repositories {
mavenCentral()
// OSS Sonatype (Snapshots) (for bungeecord-chat used by Spigot)
maven (
url = "https://oss.sonatype.org/content/repositories/snapshots/"
) {
content {
includeGroup("net.md-5")
includeGroup("org.spigotmc")
}
}
// Spigot Nexus (for Spigot API)
maven (
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
) {
content {
includeGroup("org.bukkit")
includeGroup("org.spigotmc")
}
}
}
java {
// The baseline Java version for the SpiGUI project is Java 21.
//
// The demo project should use the latest available Java (or a very recent version if the latest is
// inconvenient).
//
// Core components of SpiGUI will either use the baseline version or they will fallback to an older
// version if needed for compatibility reasons (e.g., the legacy/compat component).
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}
subprojects {
tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:all")
options.compilerArgs.add("-Werror")
}
tasks.withType<Javadoc> {
val options = options as StandardJavadocDocletOptions
if (JavaVersion.current().isJava9Compatible) {
options.addBooleanOption("html5", true)
}
options.addBooleanOption("Xdoclint:all", true)
source = sourceSets.main.get().allJava
classpath += configurations.compileClasspath.get()
options.memberLevel = JavadocMemberLevel.PRIVATE
isFailOnError = true
}
}
spotless {
format("misc") {
target("*.gradle", ".gitignore")
trimTrailingWhitespace()
leadingSpacesToTabs()
endWithNewline()
}
format("yaml") {
target("*.yaml", "*.yml")
trimTrailingWhitespace()
leadingTabsToSpaces(2)
endWithNewline()
}
java {
target(allprojects.map { it.sourceSets.main.get().allJava })
toggleOffOn()
palantirJavaFormat("2.55.0").formatJavadoc(true)
importOrder("java|javax", "org.bukkit", "com.samjakob.spigui", "")
removeUnusedImports()
}
}
tasks.named<Jar>("jar") {
enabled = false
}
val spiGUI = definePublishableArtifacts("SpiGUI", ":spigui")
val spiGUIv2 = definePublishableArtifacts("SpiGUI-v2", ":spigui-v2")
artifacts {
spiGUI.forEach { archives(it.jar) }
spiGUIv2.forEach { archives(it.jar) }
}
val defaultPublication = Action<MavenPom> {
name = "SpiGUI"
description = "A comprehensive GUI API for Spigot with pages support."
url = "https://github.com/SamJakob/SpiGUI"
packaging = "jar"
licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
}
}
developers {
developer {
name = "SamJakob"
email = "[email protected]"
organization = "SamJakob"
organizationUrl = "https://samjakob.com"
}
}
scm {
connection = "scm:git:git://github.com/SamJakob/SpiGUI.git"
developerConnection = "scm:git:ssh://github.com:SamJakob/SpiGUI.git"
url = "https://github.com/SamJakob/SpiGUI"
}
}
publishing {
publications {
create<MavenPublication>("SpiGUI") {
artifactId = "SpiGUI"
pom(defaultPublication)
spiGUI.forEach { artifact(it.jar) }
}
create<MavenPublication>("SpiGUI-v2") {
artifactId = "SpiGUI-v2"
pom(defaultPublication)
spiGUIv2.forEach { artifact(it.jar) }
}
}
if (hasSonatypeCredentials) {
repositories {
maven {
url = if (version.toString().endsWith("SNAPSHOT"))
// If the version ends with SNAPSHOT, we're building a snapshot
// so deploy to a SNAPSHOT repository.
URI("https://s01.oss.sonatype.org/content/repositories/snapshots/")
// Otherwise, deploy to a staging repository.
else URI("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = project.findProperty("ossrhUsername")!!.toString()
password = project.findProperty("ossrhPassword")!!.toString()
}
}
}
}
}
if (hasSonatypeCredentials) {
signing {
useGpgCmd()
sign(publishing.publications["SpiGUI"])
sign(publishing.publications["SpiGUI-v2"])
}
}