This repository has been archived by the owner on Jul 9, 2023. It is now read-only.
generated from MiraiMC/MiraiMC-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
117 lines (102 loc) · 3.37 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
import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id("java")
kotlin("jvm") version "1.9.0"
}
group = "moe.xmcn.catsero"
version = "3.0.1"
repositories {
maven("https://maven.fastmirror.net/repositories/minecraft")
maven("https://repo.opencollab.dev/maven-snapshots/")
maven("https://crystal.app.lss233.com/repositories/minecraft")
mavenCentral()
}
dependencies {
// 本地
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
// 远程
implementation("org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT")
implementation("org.tomlj:tomlj:1.1.0")
implementation("org.bstats:bstats-bukkit:3.0.2")
implementation("me.clip:placeholderapi:2.11.2")
implementation("io.github.dreamvoid:MiraiMC-Bukkit:1.8-pre2")
implementation("com.alibaba:fastjson:2.0.34")
implementation("com.squareup.okhttp3:okhttp:4.11.0")
//implementation("com.github.CroaBeast:AdvancementInfo:2.0.2")
//implementation("com.zaxxer:HikariCP:4.0.3")
//implementation("org.geysermc.floodgate:api:2.2.0-SNAPSHOT")
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.3")
testImplementation(kotlin("test"))
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.getByName<Test>("test") {
useJUnitPlatform()
}
tasks.compileJava {
options.encoding = "UTF-8"
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()
}
tasks.compileTestJava {
options.encoding = "UTF-8"
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()
}
tasks.compileKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
}
tasks.compileTestKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
}
// 替换资源文件的Tokens`config.groovy`
fun loadEnv(): Any {
val configFile = file("config.groovy")
val env = "prod"
val confProp = groovy.util.ConfigSlurper(env).parse(configFile.toURL())
//config.groovy配置文件,配置占位符 (@key@)
val tokens = confProp.toProperties()
logger.lifecycle("Tokens: $tokens")
return tokens;
}
fun delFiles(dir: String) {
val configs = fileTree(dir)
for (f in configs) {
f.delete()
}
}
tasks.processResources {
delFiles("$buildDir/resources")
filteringCharset = "UTF-8"
filter(ReplaceTokens::class, "tokens" to loadEnv())
filter(
FixCrLfFilter::class,
"eol" to FixCrLfFilter.CrLf.newInstance("lf"),
"tab" to FixCrLfFilter.AddAsisRemove.newInstance("asis"),
"tablength" to 4,
"eof" to FixCrLfFilter.AddAsisRemove.newInstance("remove"),
"fixlast" to true
)
}
tasks.create<Jar>("fatJar") {
duplicatesStrategy = DuplicatesStrategy.FAIL
val sourceMain = java.sourceSets["main"]
from(sourceMain.output)
configurations.runtimeClasspath.get().filter {
it.name.startsWith("AdvancementInfo") || it.name.startsWith("HikariCP")
}.forEach { jar ->
from(zipTree(jar))
}
}
//build命令依赖的其他命令
tasks.build {
dependsOn(
tasks.processResources,
"fatJar"
)
}