Skip to content

Commit 1a89f36

Browse files
authored
Merge pull request #240 from IThundxr/feat/multi-loader-1.21
Port to 1.21.1
2 parents a89756a + df8c749 commit 1a89f36

File tree

128 files changed

+1433
-1746
lines changed

Some content is hidden

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

128 files changed

+1433
-1746
lines changed

.github/workflows/build.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build
33
on: [ workflow_dispatch, pull_request, push ]
44

55
env:
6-
JAVA_VERSION: 17
6+
JAVA_VERSION: 21
77

88
jobs:
99
build:
@@ -43,13 +43,15 @@ jobs:
4343
path: |
4444
common/build/libs/
4545
fabric/build/libs/
46-
forge/build/libs/
46+
neoforge/build/libs/
47+
vanillinFabric/build/libs/
48+
vanillinNeoForge/build/libs/
4749
4850
test:
4951
strategy:
5052
fail-fast: false
5153
matrix:
52-
loader: [ forge, fabric ]
54+
loader: [ neoforge, fabric ]
5355
needs: build
5456
runs-on: ubuntu-latest
5557
steps:
@@ -63,15 +65,15 @@ jobs:
6365

6466
- name: Setup Environment Variables
6567
run: |
66-
echo "MOD_VERSION=$(grep '^mod_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV"
6768
echo "MINECRAFT_VERSION=$(grep '^minecraft_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV"
6869
echo "FABRIC_API_VERSION=$(grep '^fabric_api_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ' | sed 's/+.*//')" >> "$GITHUB_ENV"
6970
7071
- name: Move Test Mod and Flywheel into run/mods
72+
# We don't want to recreate the jar name formatting so glob everything over then remove the sources and javadoc jars
7173
run: |
7274
mkdir -p run/mods
73-
cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar run/mods
74-
cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods
75+
cp ${{ matrix.loader }}/build/libs/*.jar run/mods
76+
rm -f run/mods/*-sources.jar run/mods/*-javadoc.jar
7577
7678
# Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes
7779
- name: Run the MC client

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ repositories {
3939
}
4040
4141
dependencies {
42-
compileOnly fg.deobf("dev.engine_room.flywheel:flywheel-forge-api-${minecraft_version}:${flywheel_version}")
43-
runtimeOnly fg.deobf("dev.engine_room.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}")
42+
compileOnly fg.deobf("dev.engine_room.flywheel:flywheel-neoforge-api-${minecraft_version}:${flywheel_version}")
43+
runtimeOnly fg.deobf("dev.engine_room.flywheel:flywheel-neoforge-${minecraft_version}:${flywheel_version}")
4444
}
4545
```
4646
`${flywheel_version}` gets replaced by the version of Flywheel you want to use, eg. `1.0.0-beta`

buildSrc/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ plugins {
88
repositories {
99
gradlePluginPortal()
1010
mavenCentral()
11-
maven("https://maven.minecraftforge.net/") {
12-
name = "MinecraftForge"
11+
maven("https://maven.neoforged.net/releases/") {
12+
name = "NeoForged"
1313
}
1414
maven("https://maven.architectury.dev/") {
1515
name = "Architectury"

buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarSetExtension.kt

-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ open class JarSetExtension(private val project: Project) {
1313
return JarTaskSet.create(project, name, *sourceSetSet)
1414
}
1515

16-
fun outgoing(name: String, vararg sourceSetSet: SourceSet): JarTaskSet {
17-
return JarTaskSet.create(project, name, *sourceSetSet).also { it.createOutgoingConfiguration() }
18-
}
19-
2016
val mainSet: JarTaskSet by lazy {
2117
val jarTask = project.tasks.named<Jar>("jar")
2218
val remapJarTask = project.tasks.named<RemapJarTask>("remapJar")

buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt

+20-9
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import org.gradle.language.jvm.tasks.ProcessResources
2323
class JarTaskSet(
2424
private val project: Project,
2525
private val name: String,
26-
private val jar: TaskProvider<Jar>,
27-
private val sources: TaskProvider<Jar>,
28-
private val javadocJar: TaskProvider<Jar>,
29-
private val remapJar: TaskProvider<RemapJarTask>,
30-
private val remapSources: TaskProvider<RemapSourcesJarTask>
26+
val jar: TaskProvider<Jar>,
27+
val sources: TaskProvider<Jar>,
28+
val javadocJar: TaskProvider<Jar>,
29+
val remapJar: TaskProvider<RemapJarTask>,
30+
val remapSources: TaskProvider<RemapSourcesJarTask>
3131
) {
3232

3333
fun publish(artifactId: String) {
@@ -41,10 +41,21 @@ class JarTaskSet(
4141
}
4242
}
4343

44-
/**
45-
* Create a new configuration that can be consumed by other projects, and export the base jar.
46-
*/
47-
fun createOutgoingConfiguration() {
44+
fun outgoing(name: String) {
45+
outgoingRemapJar("${name}Remap")
46+
outgoingJar("${name}Dev")
47+
}
48+
49+
fun outgoingRemapJar(name: String) {
50+
val config = project.configurations.register(name) {
51+
isCanBeConsumed = true
52+
isCanBeResolved = false
53+
}
54+
55+
project.artifacts.add(config.name, remapJar)
56+
}
57+
58+
fun outgoingJar(name: String) {
4859
val config = project.configurations.register(name) {
4960
isCanBeConsumed = true
5061
isCanBeResolved = false
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
package dev.engine_room.gradle.platform
22

3-
import dev.engine_room.gradle.jarset.JarTaskSet
43
import net.fabricmc.loom.api.LoomGradleExtensionAPI
54
import net.fabricmc.loom.task.RemapJarTask
65
import org.gradle.api.Project
76
import org.gradle.api.Task
87
import org.gradle.api.tasks.SourceSet
9-
import org.gradle.api.tasks.SourceSetContainer
10-
import org.gradle.api.tasks.compile.JavaCompile
11-
import org.gradle.api.tasks.javadoc.Javadoc
128
import org.gradle.jvm.tasks.Jar
13-
import org.gradle.kotlin.dsl.*
14-
import org.gradle.language.jvm.tasks.ProcessResources
9+
import org.gradle.kotlin.dsl.assign
10+
import org.gradle.kotlin.dsl.named
11+
import org.gradle.kotlin.dsl.register
12+
import org.gradle.kotlin.dsl.the
1513
import java.io.File
16-
import kotlin.properties.ReadWriteProperty
17-
import kotlin.reflect.KProperty
1814

1915
open class PlatformExtension(val project: Project) {
20-
var commonProject: Project by DependentProject(this.project)
21-
22-
var modArtifactId: String = "flywheel-${project.name}-${project.property("artifact_minecraft_version")}"
23-
24-
var apiArtifactId: String = "flywheel-${project.name}-api-${project.property("artifact_minecraft_version")}"
25-
26-
private val commonSourceSets: SourceSetContainer by lazy { commonProject.the<SourceSetContainer>() }
27-
2816
fun setupLoomMod(vararg sourceSets: SourceSet) {
2917
project.the<LoomGradleExtensionAPI>().mods.maybeCreate("main").apply {
3018
sourceSets.forEach(::sourceSet)
@@ -56,52 +44,6 @@ open class PlatformExtension(val project: Project) {
5644
}
5745
}
5846

59-
fun compileWithCommonSourceSets(vararg sourceSets: SourceSet) {
60-
project.tasks.apply {
61-
withType<JavaCompile>().configureEach {
62-
JarTaskSet.excludeDuplicatePackageInfos(this)
63-
}
64-
65-
sourceSets.forEach {
66-
val commonSourceSet = commonSourceSets.named(it.name).get()
67-
68-
named<JavaCompile>(it.compileJavaTaskName).configure {
69-
source(commonSourceSet.allJava)
70-
}
71-
named<ProcessResources>(it.processResourcesTaskName).configure {
72-
from(commonSourceSet.resources)
73-
}
74-
}
75-
}
76-
}
77-
78-
fun setupFatJar(vararg sourceSets: SourceSet) {
79-
project.tasks.apply {
80-
val extraSourceSets = sourceSets.filter { it.name != "main" }.toList()
81-
val commonSources = sourceSets.map { commonSourceSets.named(it.name).get() }
82-
83-
named<Jar>("jar").configure {
84-
extraSourceSets.forEach { from(it.output) }
85-
86-
JarTaskSet.excludeDuplicatePackageInfos(this)
87-
}
88-
89-
named<Javadoc>("javadoc").configure {
90-
commonSources.forEach { source(it.allJava) }
91-
extraSourceSets.forEach { source(it.allJava) }
92-
93-
JarTaskSet.excludeDuplicatePackageInfos(this)
94-
}
95-
96-
named<Jar>("sourcesJar").configure {
97-
commonSources.forEach { from(it.allJava) }
98-
extraSourceSets.forEach { from(it.allJava) }
99-
100-
JarTaskSet.excludeDuplicatePackageInfos(this)
101-
}
102-
}
103-
}
104-
10547
fun setupTestMod(sourceSet: SourceSet) {
10648
project.tasks.apply {
10749
val testModJar = register<Jar>("testModJar") {
@@ -124,20 +66,4 @@ open class PlatformExtension(val project: Project) {
12466
}
12567
}
12668
}
127-
128-
private class DependentProject(private val thisProject: Project) : ReadWriteProperty<Any?, Project> {
129-
private var value: Project? = null
130-
131-
override fun getValue(thisRef: Any?, property: KProperty<*>): Project {
132-
return value ?: throw IllegalStateException("Property ${property.name} should be initialized before get.")
133-
}
134-
135-
override fun setValue(thisRef: Any?, property: KProperty<*>, value: Project) {
136-
this.value = value
137-
thisProject.evaluationDependsOn(value.path)
138-
}
139-
140-
override fun toString(): String =
141-
"NotNullProperty(${if (value != null) "value=$value" else "value not initialized yet"})"
142-
}
14369
}

0 commit comments

Comments
 (0)