-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
138 lines (110 loc) · 3.66 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
import java.io.FileOutputStream
import java.nio.file.Files
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
plugins {
`java-library`
id("com.github.johnrengelman.shadow") version "7.1.2"
id("xyz.jpenilla.run-paper") version "1.0.6"
// TODO:
/* id("net.minecrell.plugin-yml.bukkit") apply true
// bukkit {
// main = "e"
// name = rootProject.name
// apiVersion = "1.18"
// authors = listOf("authors")
}*/
}
buildscript {
repositories {
maven("https://plugins.gradle.org/m2/")
}
dependencies {
classpath("io.freefair.gradle:lombok-plugin:6.3.0")
classpath("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
}
}
val bundleJars by tasks.register("bundleJars", DefaultTask::class)
bundleJars.doFirst {
val zipFile = buildDir.toPath().resolve("jars.zip")
ZipOutputStream(FileOutputStream(zipFile.toFile())).use { zipOut ->
childProjects.values.map {
val path = it.tasks.named<AbstractArchiveTask>("shadowJar").flatMap { shadow -> shadow.archiveFile }.get().asFile.toPath()
zipOut.putNextEntry(ZipEntry(path.toFile().name))
Files.copy(path, zipOut)
}
}
}
tasks.runServer {
minecraftVersion("1.17.1")
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(17))
})
}
allprojects {
group = "mc.ultimatecore"
apply(plugin = "java")
apply(plugin = "io.freefair.lombok")
apply(plugin = "com.github.johnrengelman.shadow")
repositories {
mavenLocal()
mavenCentral()
maven("https://libraries.minecraft.net/")
maven("https://repo.codemc.io/repository/nms/")
maven("https://repo.codemc.org/repository/maven-public/")
maven("https://repo.rapture.pw/repository/maven-releases/")
maven("https://repo.glaremasters.me/repository/concuncan/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://jitpack.io")
maven("https://maven.enginehub.org/repo/")
}
dependencies {
compileOnly(fileTree("libs").matching {
include("**/*.jar")
})
compileOnly(rootProject.fileTree("libs").matching {
include("**/*.jar")
})
implementation("org.jetbrains:annotations:23.0.0")
}
tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
}
tasks.withType<Javadoc> {
options.encoding = Charsets.UTF_8.name()
}
tasks.withType<ProcessResources> {
filteringCharset = Charsets.UTF_8.name()
}
// val autoRelocate by tasks.register("configureShadowRelocation", com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation::class) {
// target = tasks.getByName("shadowJar") as ShadowJar?
// val packageName = "${project.group}.${project.name.toLowerCase()}"
// prefix = "$packageName.shaded"
// }
// tasks.withType<ShadowJar> {
// dependsOn(autoRelocate)
// }
java {
toolchain {
toolchain.languageVersion.set(JavaLanguageVersion.of(16))
}
}
}
afterEvaluate {
val moveJars by tasks.register("moveFiles", DefaultTask::class);
moveJars.doFirst {
this.project.tasks.runServer {
pluginJars.setFrom(childProjects.values.map {
it.tasks.named<AbstractArchiveTask>("shadowJar").flatMap { shadow -> shadow.archiveFile }.get().asFile
})
}
}
tasks.runServer {
dependsOn(moveJars)
}
}
tasks.register<Copy>("copyDevJars") {
from(layout.files("out/"))
include("*.jar")
into("../server/plugins/")
}