-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsettings.gradle
More file actions
158 lines (142 loc) · 5.25 KB
/
settings.gradle
File metadata and controls
158 lines (142 loc) · 5.25 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* This file is part of the Map Link mod
* licensed under the GNU GPL v3 License.
* (some parts of this file are originally from the Distant Horizons mod by James Seibel)
*
* Copyright (C) 2024 - 2026 Leander Knüttel and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* file changed by: Leander Knüttel
* date: 02.01.2026
*/
pluginManagement {
repositories {
maven {
name "Fabric"
url "https://maven.fabricmc.net/"
}
maven {
name "Forge"
url "https://maven.minecraftforge.net/"
}
maven {
name "NeoForge Releases"
url "https://maven.neoforged.net/releases/"
}
maven {
name "NeoForge Snapshot"
url "https://maven.neoforged.net/snapshots/"
}
maven {
name "Architectury (Better Forge because regular Forge is annoying)"
url "https://maven.architectury.dev/"
}
maven {
name "Quilt"
url "https://maven.quiltmc.org/repository/release"
}
maven { // Used for Vanilla Minecraft's libraries
name "Sponge"
url "https://repo.spongepowered.org/repository/maven-public/"
}
maven {
name "ParchmentMC"
url "https://maven.parchmentmc.org"
}
maven {
name "Spigot"
url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven { // Used for ModPublisher
name "Firstdark"
url "https://maven.firstdark.dev/releases"
}
maven {
url "https://chocolateminecraft.com/maven"
name "Xaero's Maven"
}
mavenCentral()
gradlePluginPortal()
// Not needed, but useful for debugging gradle plugins
mavenLocal()
}
}
/** Loads the VersionProperties field for the currently selected Minecraft version. */
def loadProperties() {
def defaultMcVersion = "1.20.4"
def mcVersion = ""
def mcVers = fileTree("versionProperties").files.name // Get all the files in "versionProperties"
mcVers.addAll(fileTree("versionProperties_disabled").files.name) //also include the disabled version properties (they will not be built)
for (int i = 0; i < mcVers.size(); i++) {
mcVers[i] = mcVers[i].replaceAll("\\.properties", "") // As we are getting the file names, we should remove the ".properties" at the end to get the versions
}
mcVers.sort((a,b) -> sortSemanticVersionOldestToNewest(a,b)) // Sort so it always goes from oldest to newest
int mcIndex = -1
println "Avalible MC versions: ${mcVers}"
if (hasProperty("mcVer")) {
mcVersion = mcVer
mcIndex = mcVers.indexOf(mcVer)
}
if (mcIndex == -1) {
println "No mcVer set or the set mcVer is invalid! Defaulting to ${defaultMcVersion}."
println "Tip: Use -PmcVer=\"${defaultMcVersion}\" in cmd arg to set mcVer."
mcVersion = defaultMcVersion
mcIndex = mcVers.indexOf(defaultMcVersion)
assert mcIndex != -1
}
println "Loading properties file at " + mcVersion + ".properties"
def props = new Properties()
props.load(new FileInputStream("$rootDir/versionProperties/"+"$mcVersion"+".properties"))
props.each { prop ->
gradle.ext.set(prop.key, prop.value)
}
gradle.ext.mcVers = mcVers
gradle.ext.mcIndex = mcIndex
}
/**
* input format: "major.minor.patch"
* needed so we can sort versions with different length strings
* IE: 1.21.1 should come before 1.21.10
*/
private static int sortSemanticVersionOldestToNewest(String version1, String version2)
{
String[] parts1 = version1.split("\\.");
String[] parts2 = version2.split("\\.");
int major1 = Integer.parseInt(parts1[0]);
int major2 = Integer.parseInt(parts2[0]);
if (major1 != major2)
{
return Integer.compare(major1, major2);
}
int minor1 = Integer.parseInt(parts1[1]);
int minor2 = Integer.parseInt(parts2[1]);
if (minor1 != minor2)
{
return Integer.compare(minor1, minor2);
}
int patch1 = Integer.parseInt(parts1[2]);
int patch2 = Integer.parseInt(parts2[2]);
return Integer.compare(patch1, patch2);
}
loadProperties()
// sub-projects
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)
}
rootProject.name = "maplink"