-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
257 lines (218 loc) · 7.3 KB
/
build.gradle
File metadata and controls
257 lines (218 loc) · 7.3 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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
maven {
name = "Architectury"
url = "https://maven.architectury.dev"
}
maven {
name = "Fabric"
url = "https://maven.fabricmc.net"
}
maven {
name = "Forge"
url = "https://maven.minecraftforge.net"
}
}
dependencies {
classpath("com.gradleup.shadow:shadow-gradle-plugin:8.3.6") // for shadowing
classpath("io.freefair.gradle:lombok-plugin:8.6")
// Note: Architectury Loom is applied as a plugin in subprojects, not as a classpath dependency
}
}
//plugins {
// id "maven-publish"
//}
allprojects {
apply plugin: "java"
apply plugin: "com.gradleup.shadow"
apply plugin: "io.freefair.lombok"
apply plugin: "maven-publish"
version = rootProject.properties["version"]
group = rootProject.properties["group"]
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
artifacts {
archives shadowJar
}
repositories {
// Spigot / Bukkit
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://oss.sonatype.org/content/repositories/central" }
// Paper / Velocity
maven {
name = 'papermc'
url = 'https://repo.papermc.io/repository/maven-public/'
}
// OpenCollab
maven { url 'https://repo.opencollab.dev/maven-snapshots/' }
maven { url 'https://repo.opencollab.dev/maven-releases/'}
// PlaceholderAPI
maven { url "https://repo.extendedclip.com/content/repositories/placeholderapi" }
// CodeMC
maven { url "https://repo.codemc.io/repository/maven-releases/" }
maven { url "https://repo.codemc.io/repository/maven-snapshots/" }
// Streamline Essentials repository
maven {
name = "streamline-essentials"
url = "https://repo.codemc.io/repository/streamline-essentials/"
}
// Local libs folder as a flat directory repository
flatDir {
dirs "${rootDir}/libs"
}
}
}
subprojects {
apply from: rootDir.toString() + "/dependencies.gradle"
ext {
pluginMain = rootProject.properties["plugin.main"] == "default" ?
project.group.toString() + "." + project.name.toString().toLowerCase() + "." + project.name.toString() :
properties["plugin.main"]
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
processResources {
// Debugging: Print values
doFirst {
println "Version: " + rootProject.version.toString() + ", Name: " + rootProject.name.toString() + ", Main: " + project.ext.pluginMain.toString()
}
inputs.property("name", rootProject.name.toString())
inputs.property("version", rootProject.version.toString())
inputs.property("main", project.ext.pluginMain.toString())
outputs.dir(file("build/generated-src"))
filesMatching("**/plugin.yml") {
expand (
"name": rootProject.name.toString(),
"version": rootProject.version.toString(),
)
}
filesMatching("**/velocity-plugin.json") {
expand (
"name": rootProject.name.toString(),
"version": rootProject.version.toString(),
)
}
filesMatching("**/streamline.properties") {
expand (
"name": rootProject.name.toString(),
"version": rootProject.version.toString(),
)
}
filesMatching("**/singularity.properties") {
expand (
"name": rootProject.name.toString(),
"version": rootProject.version.toString(),
)
}
filesMatching("**/fabric.mod.json") {
expand (
"name": rootProject.name.toString(),
"version": rootProject.version.toString(),
)
}
filesMatching("**/mods.toml") {
expand (
"name": rootProject.name.toString(),
"version": rootProject.version.toString(),
)
}
}
shadowJar {
manifest {
attributes(
"Implementation-Title": rootProject.name.toString(),
"Implementation-Version": rootProject.version.toString()
)
}
relocate("com.github.Anon8281.universalScheduler", "host.plas.bou.libs.universalScheduler")
relocate("ch.qos.logback", "host.plas.bou.libs.logback")
archiveFileName = project.name + "-" + project.version + ".jar"
// minimize()
}
tasks.register('deploy', Copy) {
// Define the deployment directory
def deployDir = file(System.getenv("DEPLOY_DIR") ?: "$rootDir/deploy")
// Ensure the deployment directory exists
doFirst {
println "Deploying to: $deployDir"
deployDir.mkdirs()
println "Generated JAR file: ${shadowJar.archiveFile}"
}
// Copy the shadowJar output
from shadowJar.archiveFile
into deployDir
}
// Ensure that the deploy task runs after the shadowJar task
shadowJar.finalizedBy(deploy)
tasks.named('deploy').configure {
dependsOn 'shadowJar', 'sourcesJar', 'javadocJar', 'jar'
}
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
maven(MavenPublication) {
groupId project.group
artifactId "$project.name"
version project.version
from components.java
}
}
repositories {
maven {
url = "https://repo.codemc.io/repository/streamline-essentials/"
def mavenUsername = System.getenv("JENKINS_NEXUS_USERNAME")
def mavenPassword = System.getenv("JENKINS_NEXUS_PASSWORD")
if (mavenUsername != null && mavenPassword != null) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
}
}
}
tasks.register("clearDeploys", Delete) {
// Define the deployment directory
def deployDir = file(System.getenv("DEPLOY_DIR") ?: "$rootDir/deploy")
deployDir.mkdirs()
File[] files = deployDir.listFiles()
if (files != null) {
files.each { file ->
if (file.isFile()) {
file.delete()
}
}
}
}
clean.finalizedBy(clearDeploys)
tasks.named('clearDeploys').configure {
dependsOn 'clean'
}
clearDeploys.finalizedBy(build)
tasks.named("build").configure {
doFirst {
tasks.named('clean')
}
}
build.finalizedBy(publish)
tasks.named("publish").configure {
doFirst {
tasks.named('build')
}
}
wrapper {
gradleVersion = "8.9"
distributionType = Wrapper.DistributionType.ALL
}