generated from Turnip-Labs/bta-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.gradle.kts
More file actions
60 lines (60 loc) · 1.97 KB
/
settings.gradle.kts
File metadata and controls
60 lines (60 loc) · 1.97 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
val modName: Provider<String> = providers.gradleProperty("mod_name")
rootProject.name = modName.get()
pluginManagement {
fun isRepoHealthy(url: String): Boolean {
var connection: javax.net.ssl.HttpsURLConnection? = null
return try {
connection = java.net.URI(url).toURL().openConnection() as javax.net.ssl.HttpsURLConnection
connection.requestMethod = "HEAD"
connection.connectTimeout = 2000
connection.readTimeout = 2000
connection.instanceFollowRedirects = true
connection.connect()
val code = connection.responseCode
code in 200..399
} catch (_: Exception) {
false
} finally {
connection?.disconnect()
}
}
fun repoUrlWithFallbacks(candidates: List<String>): String {
if (candidates.isEmpty()) {
val badLink = "https://mock.httpstatus.io/500"
logger.error("No repositories have been provided. Defaulting to: {}", badLink)
return badLink
}
val chosenRepository = candidates.firstOrNull { isRepoHealthy(it) } ?: run {
if (candidates.size == 1) {
logger.error("\"{}\" could not be resolved.", candidates.first())
} else {
logger.error("All {} repositories could not be resolved. Defaulting to: {}", candidates.size, candidates.first())
}
return candidates.first()
}
logger.lifecycle("Using \"{}\" as the Fabric repository.", chosenRepository)
return chosenRepository
}
repositories {
maven(
repoUrlWithFallbacks(
listOf(
"https://maven.fabricmc.net",
"https://maven2.fabricmc.net",
"https://maven3.fabricmc.net"
)
)
) { name = "Fabric" }
maven("https://jitpack.io") { name = "Jitpack" }
maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" }
mavenCentral()
gradlePluginPortal()
}
val foojayResolverVersion = providers.gradleProperty("foojay_resolver_version")
plugins {
id("org.gradle.toolchains.foojay-resolver-convention").version(foojayResolverVersion.get())
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention")
}