-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsettings.gradle
More file actions
77 lines (69 loc) · 2.49 KB
/
Copy pathsettings.gradle
File metadata and controls
77 lines (69 loc) · 2.49 KB
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
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.neoforged.net/releases' }
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
def requestedTasks = gradle.startParameter.taskNames
def needsT88Bootstrap = requestedTasks.any { name ->
name == "jarFromScratch" || name.endsWith(":jarFromScratch")
}
if (needsT88Bootstrap) {
new T88Bootstrap(settings.rootDir, providers).run()
}
class T88Bootstrap {
private static final String REPO_URL = "https://github.com/USS-Shenzhou/t88.git"
private final File rootDir
private final ProviderFactory providers
T88Bootstrap(File rootDir, ProviderFactory providers) {
this.rootDir = rootDir
this.providers = providers
}
void run() {
def workDir = new File(rootDir, "build/t88-source")
def gitDir = new File(workDir, ".git")
if (gitDir.isDirectory()) {
runCommand(workDir, "git", "pull", "--ff-only")
} else {
if (workDir.exists()) {
workDir.deleteDir()
}
workDir.parentFile.mkdirs()
runCommand(workDir.parentFile,
"git", "clone", "--depth=1", REPO_URL, workDir.name)
}
def isWindows = System.getProperty("os.name").toLowerCase().contains("win")
def wrapperName = isWindows ? "gradlew.bat" : "gradlew"
def wrapper = new File(workDir, wrapperName)
if (!wrapper.exists()) {
throw new GradleException("t88 working tree is missing ${wrapperName} at ${wrapper}")
}
if (!isWindows) {
wrapper.setExecutable(true)
}
runCommand(workDir, wrapper.absolutePath, "publishToMavenLocal")
}
private void runCommand(File workingDir, String... command) {
def execOutput = providers.exec { spec ->
spec.commandLine = command.toList()
spec.workingDir = workingDir
spec.ignoreExitValue = true
}
def result = execOutput.result.get()
def stdoutText = execOutput.standardOutput.asText.get()
def stderrText = execOutput.standardError.asText.get()
if (stdoutText) {
println stdoutText
}
if (result.exitValue != 0) {
throw new GradleException(
"Command failed (exit ${result.exitValue}): ${command.join(' ')}\n" +
"stderr:\n${stderrText}"
)
}
}
}