-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
84 lines (66 loc) · 2.22 KB
/
build.gradle
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
plugins {
id "java"
}
group = "io.github.evercraftmc"
version = core_version
repositories {
mavenCentral()
}
subprojects {
group = "io.github.evercraftmc.evercraft"
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(java_version)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
}
}
if (System.getenv("EVERCRAFT_PATH") != null && System.getenv("EVERCRAFT_SERVERS") != null) {
def path = System.getenv("EVERCRAFT_PATH")
if (!path.endsWith("/")) {
path = path + "/"
}
def servers = System.getenv("EVERCRAFT_SERVERS").split(";")
for (def serverDef : servers) {
def server = serverDef.split(":", 4)
def serverId = server[0]
def serverName = server[1]
def moduleNames = server[2].split(",")
def uploadPath = server[3]
if (!uploadPath.startsWith("/")) {
uploadPath = "/" + uploadPath
}
if (!uploadPath.endsWith("/")) {
uploadPath = uploadPath + "/"
}
for (def moduleName : moduleNames) {
final def moduleNameCp = moduleName
final def toPath = path + serverId + uploadPath + "EverCraft-" + moduleName + ".jar"
tasks.register("upload-${serverName}-${moduleName}", Exec) {
dependsOn project(":" + moduleNameCp).tasks.fatJar
final def fromPath = project(":" + moduleNameCp).tasks.fatJar.outputs.files[0].toPath().toAbsolutePath().toString()
commandLine "rsync", "-q", fromPath, toPath
}
}
}
tasks.register("upload") {
dependsOn subprojects.collect {
it.tasks.fatJar
}
for (def serverDef : servers) {
def server = serverDef.split(":", 4)
def serverName = server[1]
def moduleNames = server[2].split(",")
for (def moduleName : moduleNames) {
dependsOn tasks.named("upload-${serverName}-${moduleName}")
}
}
}
} else {
logger.log(LogLevel.WARN, "Missing or EVERCRAFT_PATH or EVERCRAFT_SERVERS environment variables, uploading will be disabled")
}