This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbuildJava.js
37 lines (32 loc) · 1.52 KB
/
buildJava.js
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
const { exec } = require("child_process");
const { readdirSync, fstat, rmSync } = require('fs')
function comm(com) {
return new Promise(r => {
exec(com, () => { r() })
})
}
async function compileFile(feature, file) {
console.log("Compiling " + feature + "/" + file + ".java")
await comm("javac -cp C:/Users/adam_/.gradle/caches/essential-loom/1.8.9/de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9/minecraft-mapped.jar;C:/Users/adam_/.gradle/caches/essential-loom/1.8.9/de.oceanlabs.mcp.mcp_stable.1_8_9.22-1.8.9-forge-1.8.9-11.15.1.2318-1.8.9/forge/forge-mapped.jar -source 8 -target 8 src/features/" + feature + "/" + file + ".java")
await comm("java -jar thingoidk.jar src/features/" + feature + "/" + file + ".class ../SoopyV2/features/" + feature + "/")
rmSync("src/features/" + feature + "/" + file + ".class")
}
const getDirectories = source =>
readdirSync(source, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name)
const getJava = source =>
readdirSync(source, { withFileTypes: true })
.filter(dirent => !dirent.isDirectory())
.map(dirent => dirent.name)
.filter(dirent => dirent.endsWith(".java"))
async function compileAll() {
let features = getDirectories("src/features")
for (let feature of features) {
let javas = getJava("src/features/" + feature)
for (let java of javas) {
await compileFile(feature, java.replace(".java", ""))
}
}
}
compileAll()