Skip to content

Commit 4f51532

Browse files
authored
Merge pull request #13 from MicrocontrollersDev/twoconfig
2 parents 5622b55 + de3aee0 commit 4f51532

77 files changed

Lines changed: 395 additions & 2377 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build.gradle.kts

Lines changed: 92 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,104 @@
1-
@file:Suppress("UnstableApiUsage", "PropertyName")
2-
3-
import dev.deftu.gradle.utils.GameSide
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
43

54
plugins {
6-
java
7-
kotlin("jvm")
8-
id("dev.deftu.gradle.multiversion") // Applies preprocessing for multiple versions of Minecraft and/or multiple mod loaders.
9-
id("dev.deftu.gradle.tools") // Applies several configurations to things such as the Java version, project name/version, etc.
10-
id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources.
11-
id("dev.deftu.gradle.tools.bloom") // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files.
12-
id("dev.deftu.gradle.tools.shadow") // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those!
13-
id("dev.deftu.gradle.tools.ducks") // Creates a ducks source set, which allows us to use theoretical classes which may not exist at runtime (such as things which are in other mods).
14-
id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you.
15-
id("dev.deftu.gradle.tools.minecraft.releases") // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth.
16-
}
17-
18-
toolkitLoomHelper {
19-
useOneConfig {
20-
version = "1.0.0-alpha.174"
21-
loaderVersion = "1.1.0-alpha.53"
22-
usePolyMixin = true
23-
polyMixinVersion = "0.8.4+build.7"
24-
applyLoaderTweaker = true
25-
for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) {
26-
+module
27-
}
28-
}
5+
id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT"
6+
id("org.jetbrains.kotlin.jvm") version "2.3.0"
7+
id("dev.deftu.gradle.bloom") version "0.2.0"
8+
}
299

30-
useDevAuth("1.2.1")
31-
useMixinExtras("0.5.0")
10+
val modid = property("mod.id")
11+
val modname = property("mod.name")
12+
val modversion = property("mod.version")
13+
val mcversion = property("minecraft_version")
3214

33-
// Turns off the server-side run configs, as we're building a client-sided mod.
34-
disableRunConfigs(GameSide.SERVER)
15+
base {
16+
archivesName.set(property("mod.id") as String)
17+
}
18+
19+
repositories {
20+
maven("https://maven.parchmentmc.org")
21+
maven("https://repo.polyfrost.org/releases")
22+
maven("https://repo.polyfrost.org/snapshots")
23+
maven("https://maven.gegy.dev/releases")
24+
}
3525

36-
// Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes.
37-
if (!mcData.isNeoForge) {
38-
useMixinRefMap(modData.id)
26+
loom {
27+
runConfigs.all {
28+
ideConfigGenerated(stonecutter.current.isActive)
29+
runDir = "../../run" // This sets the run folder for all mc versions to the same folder. Remove this line if you want individual run folders.
3930
}
4031

41-
if (mcData.isForge) {
42-
// Configures the Mixin tweaker if we are building for Forge.
43-
useForgeMixin(modData.id)
32+
runConfigs.remove(runConfigs["server"]) // Removes server run configs
33+
}
34+
35+
dependencies {
36+
minecraft("com.mojang:minecraft:${property("minecraft_version")}")
37+
@Suppress("UnstableApiUsage")
38+
mappings(loom.layered {
39+
officialMojangMappings()
40+
optionalProp("${property("parchment_version")}") {
41+
parchment("org.parchmentmc.data:parchment-${property("minecraft_version")}:$it@zip")
42+
}
43+
optionalProp("${property("yalmm_version")}") {
44+
mappings("dev.lambdaurora:yalmm-mojbackward:${property("minecraft_version")}+build.$it")
45+
}
46+
})
47+
modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}")
48+
modImplementation("org.polyfrost.oneconfig:${property("minecraft_version")}-fabric:1.0.0-alpha.181")
49+
modImplementation("org.polyfrost.oneconfig:commands:1.0.0-alpha.181")
50+
modImplementation("org.polyfrost.oneconfig:config:1.0.0-alpha.181")
51+
modImplementation("org.polyfrost.oneconfig:config-impl:1.0.0-alpha.181")
52+
modImplementation("org.polyfrost.oneconfig:events:1.0.0-alpha.181")
53+
modImplementation("org.polyfrost.oneconfig:internal:1.0.0-alpha.181")
54+
modImplementation("org.polyfrost.oneconfig:ui:1.0.0-alpha.181")
55+
modImplementation("org.polyfrost.oneconfig:utils:1.0.0-alpha.181")
56+
modImplementation("org.polyfrost.oneconfig:hud:1.0.0-alpha.181")
57+
}
58+
59+
bloom {
60+
replacement("@MOD_ID@", modid!!)
61+
replacement("@MOD_NAME@", modname!!)
62+
replacement("@MOD_VERSION@", modversion!!)
63+
}
64+
65+
tasks.processResources {
66+
val props = mapOf(
67+
"mod_id" to modid,
68+
"mod_name" to modname,
69+
"mod_version" to modversion,
70+
"mc_version" to mcversion,
71+
"loader_version" to providers.gradleProperty("loader_version").get()
72+
)
73+
74+
inputs.properties(props)
75+
76+
filesMatching("fabric.mod.json") {
77+
expand(props)
4478
}
4579
}
4680

81+
tasks.withType<JavaCompile>().configureEach {
82+
options.release.set(21)
83+
}
84+
85+
tasks.withType<KotlinCompile>().configureEach {
86+
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
87+
}
88+
89+
java {
90+
withSourcesJar()
91+
sourceCompatibility = JavaVersion.VERSION_21
92+
targetCompatibility = JavaVersion.VERSION_21
93+
}
94+
4795
tasks.jar {
48-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
96+
inputs.property("archivesName", base.archivesName)
97+
98+
from("LICENSE") {
99+
rename { "${it}_${inputs.properties["archivesName"]}" }
100+
}
49101
}
102+
103+
fun <T> optionalProp(property: String, block: (String) -> T?): T? =
104+
findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block)

gradle.properties

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
# gradle.properties file -- CHANGE THE VALUES STARTING WITH `mod_*` AND REMOVE THIS COMMENT.
2-
3-
# Sets the name of your mod.
41
mod.name=PolyNametag
5-
# Sets the id of your mod that mod loaders use to recognize it.
62
mod.id=polynametag
7-
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
83
mod.version=1.1.0-alpha.1
9-
# Sets the name of the jar file that you put in your 'mods' folder.
104
mod.group=org.polyfrost
115

12-
# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
6+
loom_version=1.14-SNAPSHOT
7+
loader_version=0.18.4
8+
minecraft_version=[VERSIONED]
9+
parchment_version=[VERSIONED]
10+
yalmm_version=[VERSIONED]
11+
1312
org.gradle.daemon=true
1413
org.gradle.parallel=true
1514
org.gradle.configureoncommand=true
1615
org.gradle.parallel.threads=4
17-
org.gradle.jvmargs=-Xmx8G
18-
loom.ignoreDependencyLoomVersionValidation=true
19-
dgt.minecraft.revision=3
20-
essential.loom.disableUnpick=true
16+
org.gradle.jvmargs=-Xmx2G
17+
18+
# Fix YALMM
19+
fabric.loom.dropNonIntermediateRootMethods=true

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

root.gradle.kts

Lines changed: 0 additions & 56 deletions
This file was deleted.

settings.gradle.kts

Lines changed: 22 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,35 @@
1-
@file:Suppress("PropertyName")
2-
3-
import groovy.lang.MissingPropertyException
4-
51
pluginManagement {
62
repositories {
7-
// Releases
8-
maven("https://maven.deftu.dev/releases")
3+
mavenCentral()
4+
gradlePluginPortal()
95
maven("https://maven.fabricmc.net")
10-
maven("https://maven.architectury.dev/")
11-
maven("https://maven.minecraftforge.net")
12-
maven("https://repo.essential.gg/repository/maven-public")
13-
maven("https://server.bbkr.space/artifactory/libs-release/")
6+
maven("https://maven.kikugie.dev/snapshots")
7+
maven("https://maven.kikugie.dev/releases")
148
maven("https://jitpack.io/")
15-
16-
// Snapshots
9+
maven("https://maven.deftu.dev/releases")
1710
maven("https://maven.deftu.dev/snapshots")
18-
mavenLocal()
19-
20-
// Default
21-
gradlePluginPortal()
22-
mavenCentral()
23-
}
24-
25-
plugins {
26-
kotlin("jvm") version ("2.2.10")
27-
id("dev.deftu.gradle.multiversion-root") version ("2.59.0")
11+
maven("https://maven.architectury.dev")
12+
maven("https://repo.polyfrost.org/releases")
13+
maven("https://repo.polyfrost.org/snapshots")
2814
}
2915
}
3016

31-
val projectName: String = extra["mod.name"]?.toString()
32-
?: throw MissingPropertyException("mod.name has not been set.")
33-
34-
// Configures the root project Gradle name based on the value in `gradle.properties`
35-
rootProject.name = projectName
36-
rootProject.buildFileName = "root.gradle.kts"
37-
38-
// Adds all of our build target versions to the classpath if we need to add version-specific code.
39-
// Update this list if you want to remove/add a version and/or mod loader.
40-
// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc)
41-
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` FILE WITH THE NEW VERSION(S).
42-
listOf(
43-
"1.8.9-forge",
44-
"1.8.9-fabric",
45-
46-
"1.12.2-forge",
47-
"1.12.2-fabric",
48-
49-
"1.16.5-forge",
50-
"1.16.5-fabric",
51-
52-
"1.20.1-forge",
53-
"1.20.1-fabric",
54-
55-
"1.20.4-forge",
56-
"1.20.4-neoforge",
57-
"1.20.4-fabric",
58-
59-
"1.21.1-neoforge",
60-
"1.21.1-fabric",
61-
62-
"1.21.4-neoforge",
63-
"1.21.4-fabric",
17+
plugins {
18+
id("dev.kikugie.stonecutter") version "0.7.10"
19+
}
6420

65-
"1.21.5-neoforge",
66-
"1.21.5-fabric",
21+
stonecutter {
22+
create(rootProject) {
23+
versions("1.21.1", "1.21.8", "1.21.10")
6724

68-
"1.21.8-neoforge",
69-
"1.21.8-fabric",
25+
vcsVersion = "1.21.10"
26+
}
27+
}
7028

71-
"1.21.10-neoforge",
72-
"1.21.10-fabric",
73-
).forEach { version ->
74-
include(":$version")
75-
project(":$version").apply {
76-
projectDir = file("versions/$version")
77-
buildFileName = "../../build.gradle.kts"
29+
dependencyResolutionManagement {
30+
versionCatalogs {
31+
create("libs")
7832
}
7933
}
34+
35+
rootProject.name = "PolyNametag"

0 commit comments

Comments
 (0)