-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettings.gradle
73 lines (67 loc) · 3.13 KB
/
settings.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
pluginManagement {
repositories {
maven { // Used for Vanilla Minecraft's libraries
name = 'Sponge'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Architectury'
url = 'https://maven.architectury.dev/'
}
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}
/**
* Add Minecraft version-specific properties to build properties
*/
def loadProperties() {
String defaultMinecraftVersion = '1.20.2'
String currentTargetMinecraftVersion = ''
ArrayList<String> targetMinecraftVersionsList = fileTree('versionProperties').files.name // Get all the files in "versionProperties"
for (int i = 0; i < targetMinecraftVersionsList.size(); i++) {
targetMinecraftVersionsList[i] = targetMinecraftVersionsList[i].replaceAll('\\.properties', '') // As we are getting the file names, we should remove the ".properties" at the end to get the versions
}
targetMinecraftVersionsList.sort() // Sort so it always goes from oldest to newest
int minecraftVersionIndex = -1
println "Available MC versions: ${targetMinecraftVersionsList}"
if (hasProperty('targetMinecraftVersion')) {
currentTargetMinecraftVersion = targetMinecraftVersion
minecraftVersionIndex = targetMinecraftVersionsList.indexOf(targetMinecraftVersion)
}
if (minecraftVersionIndex == -1) {
println 'No targetMinecraftVersion set or the set targetMinecraftVersion is invalid! Defaulting to ' + defaultMinecraftVersion + '.'
println 'Tip: Use -PtargetMinecraftVersion="' + defaultMinecraftVersion + '" in cmd arg to set targetMinecraftVersion.'
currentTargetMinecraftVersion = defaultMinecraftVersion
minecraftVersionIndex = targetMinecraftVersionsList.indexOf(defaultMinecraftVersion)
assert minecraftVersionIndex != -1
}
println 'Loading properties file at ' + currentTargetMinecraftVersion + '.properties'
Properties props = new Properties()
props.load(new FileInputStream(String.valueOf(rootDir) + '/versionProperties/' +"$currentTargetMinecraftVersion"+ '.properties'))
props.each { prop ->
gradle.ext.set(prop.key, prop.value)
println "Added prop [key:" + prop.key + ", value:" + prop.value + "]"
}
gradle.ext.targetMinecraftVersions = targetMinecraftVersionsList
gradle.ext.targetMinecraftVersionIndex = minecraftVersionIndex
}
loadProperties()
include('common')
// Enables or disables the subprojects depending on whats in the versionProperties/mcVer.properties
for (loader in ((String) gradle.builds_for).split(',')) {
def loaderName = loader.strip() // Strip it in case a space is added before or after the comma
println "Adding loader " + loaderName
include(loaderName)
}