forked from iceBear67/ManHunt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
90 lines (82 loc) · 3.75 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
85
86
87
88
89
90
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Files
import java.util.concurrent.TimeUnit
plugins {
id "java"
id 'com.github.johnrengelman.shadow' version "6.0.0"
}
group = 'io.ib67'
version = '1.2'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
maven {
name = 'jitpack'
url = "https://jitpack.io"
}
}
dependencies {
// https://mvnrepository.com/artifact/junit/junit
testCompile group: 'junit', name: 'junit', version: '4.13'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
testCompile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
testCompile 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
compileOnly 'com.github.PlaceholderAPI:PlaceholderAPI:2.10.9'
// https://mvnrepository.com/artifact/org.projectlombok/lombok
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.12'
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.12'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
tasks.shadowJar.finalizedBy(tasks.test)
task ci {}
tasks.ci.dependsOn tasks.shadowJar
tasks.ci.doLast {
if(!System.getProperty("user.name").equals("runner")){
System.out.println("Not CI User,Skip!");
return;
}
File SPIGOT_ROOT = new File("./spigot");
SPIGOT_ROOT.mkdir();
System.out.println("Downloading Spigot...");
File SPIGOT_JAR = new File("./spigot/spigot.jar");
new URL("https://serverjars.com/api/fetchJar/spigot/1.16").withInputStream{ i -> SPIGOT_JAR.withOutputStream{ it << i }}
System.out.println("Setting up...");
new File("./spigot/eula.txt").createNewFile();
Files.write(new File("./spigot/eula.txt").toPath(),("#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).\n" +
"#Sat May 15 14:07:13 CST 2021\n" +
"eula=true\n").getBytes());
File PLUGIN_DIR=new File("./spigot/plugins");
File OUR_JAR = new File("./build/libs/ManHunt-1.2-all.jar");
PLUGIN_DIR.mkdir();
Files.copy(OUR_JAR.toPath(),new File(PLUGIN_DIR,"ManiHunt.jar").toPath());
File PAPI = new File("./spigot/plugins/PAPI.jar");
new URL("https://github.com/PlaceholderAPI/PlaceholderAPI/releases/download/2.10.9/PlaceholderAPI-2.10.9.jar").withInputStream{ i -> PAPI.withOutputStream{ it << i }}
//HttpRequest.get("https://github.com/PlaceholderAPI/PlaceholderAPI/releases/download/2.10.9/PlaceholderAPI-2.10.9.jar").receive(PAPI);
Process b = new ProcessBuilder().directory(SPIGOT_ROOT)
.command("java","-jar","spigot.jar",
"-W","/home/runner/work/ManiHunt/ManiHunt/ci",
"--bukkit-settings","/home/runner/work/ManiHunt/ManiHunt/ci/bukkit.yml",
"--config","/home/runner/work/ManiHunt/ManiHunt/ci/server.properties"
).start();
b.waitFor(12, TimeUnit.SECONDS)
//boolean a=Files.readAllLines(new File(SPIGOT_ROOT,"logs/latest.log").toPath()).stream().anyMatch(e->e.contains("ManHunt Started! We're waiting for more players."))?false:true;
boolean a = new File("./spigot/mh_run_success").exists();
System.out.println(new String(Files.readAllBytes(new File(SPIGOT_ROOT,"logs/latest.log").toPath())))
if(!a){
throw new RuntimeException("ManiHunt didn't load successfully.");
}
}