-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
128 lines (108 loc) · 3.16 KB
/
build.gradle.kts
File metadata and controls
128 lines (108 loc) · 3.16 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
plugins {
java
id("com.github.johnrengelman.shadow") version "8.1.1"
`maven-publish`
}
group = "djkingcraftero"
version = "1.1.0"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
withSourcesJar()
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://oss.sonatype.org/content/groups/public/")
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT")
compileOnly("net.kyori:adventure-text-minimessage:4.14.0")
compileOnly("net.kyori:adventure-text-serializer-legacy:4.14.0")
testImplementation(platform("org.junit:junit-bom:5.11.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.test {
useJUnitPlatform()
}
tasks.processResources {
filesMatching("plugin.yml") {
expand("version" to project.version)
}
}
tasks.jar {
archiveBaseName.set("Jump_Block")
}
tasks.shadowJar {
archiveBaseName.set("Jump_Block")
archiveClassifier.set("")
minimize()
// Excluir archivos innecesarios para reducir tamaño
exclude("META-INF/maven/**")
exclude("META-INF/gradle/**")
exclude("**/*.kotlin_metadata")
exclude("**/*.kotlin_builtins")
}
// Tras crear el JAR, despliega automáticamente al directorio de plugins
tasks.named("shadowJar") {
finalizedBy("deploy")
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
groupId = project.group.toString()
artifactId = "Jump_Block"
version = project.version.toString()
}
}
repositories {
maven {
name = "localRepo"
url = uri(layout.buildDirectory.dir("repo"))
}
}
}
tasks.register<Copy>("dist") {
dependsOn(tasks.shadowJar)
from(tasks.shadowJar)
into(layout.projectDirectory.dir("dist"))
}
val serverPluginsDir: String? = (providers.gradleProperty("serverPluginsDir").orNull
?: System.getenv("SERVER_PLUGINS_DIR"))
tasks.register<Copy>("copyToServer") {
dependsOn(tasks.shadowJar)
val targetDir = if (serverPluginsDir == null) {
val def = layout.projectDirectory.dir("server/plugins").asFile
def.mkdirs()
def
} else {
file(serverPluginsDir)
}
from(tasks.shadowJar)
into(targetDir)
doFirst {
// Eliminar JARs antiguos del mismo plugin para evitar duplicados
val base = "Jump_Block"
targetDir.listFiles()?.filter { it.isFile && it.name.startsWith(base) && it.name.endsWith(".jar") }?.forEach { it.delete() }
}
}
tasks.register("deploy") {
dependsOn("copyToServer")
}
val serverStartBat: String? = (providers.gradleProperty("serverStartBat").orNull
?: System.getenv("SERVER_START_BAT"))
tasks.register<Exec>("runServer") {
if (serverStartBat == null) {
doFirst {
throw GradleException("Define serverStartBat=-PserverStartBat=RUTA o env SERVER_START_BAT")
}
} else {
commandLine("cmd", "/c", serverStartBat)
workingDir = file(serverPluginsDir ?: projectDir)
}
}
tasks.register("deployAndRun") {
dependsOn("deploy", "runServer")
}