-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.neoforge.gradle.kts
More file actions
139 lines (113 loc) · 3.98 KB
/
Copy pathbuild.neoforge.gradle.kts
File metadata and controls
139 lines (113 loc) · 3.98 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
plugins {
id("net.neoforged.moddev") version "2.0.140"
id("neoforge-mutex")
id("me.modmuss50.mod-publish-plugin") version "2.0.1"
}
version = "${property("mod.version")}+${sc.current.version}"
base.archivesName = "${property("mod.id") as String}-neoforge"
val requiredJava = when {
sc.current.parsed >= "26.1" -> JavaVersion.VERSION_25
sc.current.parsed >= "1.20.5" -> JavaVersion.VERSION_21
sc.current.parsed >= "1.18" -> JavaVersion.VERSION_17
sc.current.parsed >= "1.17" -> JavaVersion.VERSION_16
else -> JavaVersion.VERSION_1_8
}
repositories {
/**
* Restricts dependency search of the given [groups] to the [maven URL][url],
* improving the setup speed.
*/
fun strictMaven(url: String, alias: String, vararg groups: String) = exclusiveContent {
forRepository { maven(url) { name = alias } }
filter { groups.forEach(::includeGroup) }
}
strictMaven("https://www.cursemaven.com", "CurseForge", "curse.maven")
strictMaven("https://api.modrinth.com/maven", "Modrinth", "maven.modrinth")
maven("https://maven.shedaniel.me/")
}
neoForge {
version = property("deps.neo_loader") as String
mods {
register(property("mod.id") as String) {
sourceSet(sourceSets.main.get())
}
}
runs {
register("client") {
gameDirectory = file("../../run/")
client()
}
register("server") {
gameDirectory = file("../../run/")
server()
}
}
dependencies {
//Cloth config
val clothConfig = property("deps.cloth_config") as String
api ("me.shedaniel.cloth:cloth-config-neoforge:$clothConfig")
}
}
dependencies {
val yamlVersion = property("deps.yaml").toString()
val yamlCoords = "org.yaml:snakeyaml"
jarJar(yamlCoords) {
this as ExternalModuleDependency
version {
prefer(yamlVersion)
}
}
implementation("$yamlCoords:$yamlVersion")
if (stonecutter.eval(stonecutter.current.version, "=1.21.1")) {
"additionalRuntimeClasspath"("$yamlCoords:$yamlVersion")
}
}
java {
withSourcesJar()
targetCompatibility = requiredJava
sourceCompatibility = requiredJava
}
tasks {
processResources {
fun MutableMap<String, String>.register(key: String, property: String) {
val value: String = sc.properties[property]
inputs.property(key, value)
set(key, value)
}
val props = buildMap {
register("id", "mod.id")
register("name", "mod.name")
register("version", "mod.version")
register("minecraft", "mod.mc_compat")
}
filesMatching("META-INF/neoforge.mods.toml") { expand(props) }
val mixinJava = "JAVA_${requiredJava.majorVersion}"
filesMatching("*.mixins.json") { expand("java" to mixinJava) }
exclude("fabric.mod.json", "*.ct", "*.classtweaker")
}
named("createMinecraftArtifacts") {
dependsOn("stonecutterGenerate")
}
register<Copy>("buildAndCollect") {
group = "build"
description = "Builds mod jars and copies results to `build/libs/{mod version}/`"
inputs.property("version", project.property("mod.version"))
from(jar.flatMap { it.archiveFile }, named<Jar>("sourcesJar").flatMap { it.archiveFile })
into(rootProject.layout.buildDirectory.file("libs/${project.property("mod.version")}"))
}
}
publishMods {
val mrToken = providers.environmentVariable("MODRINTH_TOKEN")
val modVersion = "${project.property("mod.version")}+${stonecutter.current.version}"
type.set(BETA)
file.set( tasks.jar.map { it.archiveFile.get() })
changelog.set(provider { rootProject.file("CHANGELOG.md").readText() })
modLoaders.add("neoforge")
version.set(modVersion)
displayName.set(modVersion)
modrinth {
projectId = "rOrXjyPb"
accessToken = mrToken
minecraftVersions.add(stonecutter.current.version)
}
}