Skip to content

Commit

Permalink
using stonecutter for multiple versions
Browse files Browse the repository at this point in the history
removed forgix for now

needs work on the properties values on the fabric.mod.json and neoforge.mods.toml

removed deprecated getFormatting()
  • Loading branch information
Kyagara committed Oct 10, 2024
1 parent 1120f5b commit 6a5863d
Show file tree
Hide file tree
Showing 38 changed files with 190 additions and 228 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ jobs:
run: chmod +x ./gradlew

- name: Build
run: ./gradlew build
run: ./gradlew chiseledBuildAndCollect

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/
path: |
./versions/**/build/libs/*fabric.jar
./versions/**/build/libs/*neoforge.jar
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ goal with this is to add on the coop experience I really enjoyed from Cooperativ

- Enable/disable modules, allow option to disable the relay but not the syncing.
- Maybe use a small database library for storage as it might be useful for other ideas.
- Build system needs some work, shadowing is probably not done right, add sources to the artifacts.
- Maybe add back the merged jars, add sources to the artifacts.
- Add Discord commands to retrieve general information about the server, TPS, etc.

## Configuration
Expand Down
138 changes: 90 additions & 48 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,73 +1,115 @@
plugins {
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id "architectury-plugin" version "3.4-SNAPSHOT"
id "com.gradleup.shadow" version "8.3.2" apply false

id "io.github.pacifistmc.forgix" version "1.2.9"
id "dev.architectury.loom" version "1.7-SNAPSHOT"
id "com.gradleup.shadow" version "8.3.2"
}

architectury {
minecraft = project.minecraft_version
}
def loader = property("loom.platform")
def isFabric = loader == "fabric"

allprojects {
group = project.maven_group
version = project.mod_version
def minecraft_version = property("deps.minecraft")
def mod_version = property("mod.version")

base {
archivesName = property("mod.name") + "-" + mod_version + "-" + minecraft_version + "+" + loader
}

forgix {
group = project.maven_group
mergedJarName = "cooptweaks-${project.mod_version}-fabric-neoforge.jar"
outputDir = "build"
repositories {
maven { url "https://maven.neoforged.net/releases" }
}

if (findProject(":neoforge")) {
neoforge {
jarLocation = "build/libs/cooptweaks-neoforge-${project.mod_version}.jar"
loom {
decompilers {
vineflower { // Adds names to lambdas - useful for mixins
options.put("mark-corresponding-synthetics", "1")
}
}

if (findProject(":fabric")) {
fabric {
jarLocation = "build/libs/cooptweaks-fabric-${project.mod_version}.jar"
}
runConfigs.all {
ideConfigGenerated true
vmArgs "-Dmixin.debug.export=true"
runDir = "../../run"
}
}

subprojects {
apply plugin: "dev.architectury.loom"
apply plugin: "architectury-plugin"

base {
archivesName = "$project.archives_name-$project.name"
configurations {
shadowBundle {
canBeResolved = true
canBeConsumed = false
}
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
dependencies {
minecraft "net.minecraft:minecraft:${minecraft_version}"

mappings loom.layered {
it.mappings "net.fabricmc:yarn:${property("deps.yarn")}:v2"
it.mappings "dev.architectury:yarn-mappings-patch-neoforge:${property("deps.yarn_mappings_neoforge_patch")}"
}

dependencies {
minecraft "net.minecraft:minecraft:$project.minecraft_version"
mappings loom.layered {
it.mappings("net.fabricmc:yarn:$project.yarn_mappings:v2")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$project.yarn_mappings_patch_neoforge_version")
}
if (isFabric) {
modImplementation "net.fabricmc:fabric-loader:${property("deps.fabric_loader")}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${property("deps.fabric_api")}"
} else {
neoForge "net.neoforged:neoforge:${property("deps.neoforge")}"
}

java {
withSourcesJar()
modImplementation "dev.architectury:architectury-${loader}:${property("deps.architectury_api")}"

shadowBundle implementation("com.discord4j:discord4j-core:${property("deps.discord4j")}")
}

tasks.processResources {
def props = [
version : mod_version,
minecraft: minecraft_version,
]

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
filesMatching("fabric.mod.json") { expand(props) }
filesMatching("META-INF/neoforge.mods.toml") { expand(props) }
filesMatching("cooptweaks.mixins.json") { expand(props) }
}

tasks.register('buildAndCollect', Copy) {
group = 'build'
from(tasks.remapJar.archiveFile)
into(rootProject.layout.buildDirectory.file("libs/"))
dependsOn('build')
}

shadowJar {
configurations = [project.configurations.shadowBundle]
archiveClassifier = "dev-shadow"

relocate 'io.netty', 'shadow.io.netty'
relocate 'org.checkerframework', 'shadow.org.checkerframework'
relocate 'com.google', 'shadow.com.google'
}

remapJar {
dependsOn(shadowJar)
inputFile = tasks.shadowJar.archiveFile
}

afterEvaluate {
stonecutter {
stonecutter.const("fabric", loader == "fabric")
stonecutter.const("neoforge", loader == "neoforge")
}
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
if (stonecutter.current.isActive) {
rootProject.tasks.register("buildActive") {
group = "project"
dependsOn(tasks.named("build"))
}
}

java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

build.finalizedBy(mergeJars)
assemble.finalizedBy(mergeJars)
tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}
15 changes: 0 additions & 15 deletions common/build.gradle

This file was deleted.

63 changes: 0 additions & 63 deletions fabric/build.gradle

This file was deleted.

32 changes: 18 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.parallel=true

# Mod properties
mod_version=0.3.0
maven_group=com.cooptweaks
archives_name=cooptweaks
enabled_platforms=fabric,neoforge

# Minecraft properties
minecraft_version=1.21.1
yarn_mappings=1.21+build.3
yarn_mappings_patch_neoforge_version=1.21+build.4
mod.id=cooptweaks
mod.version=0.3.0
mod.group=com.cooptweaks
mod.name=CoopTweaks

# Dependencies
discord4j_version=3.2.6
architectury_api_version=13.0.6
fabric_loader_version=0.16.5
fabric_api_version=0.105.0+1.21.1
neoforge_version=21.1.61
deps.minecraft=[VERSIONED]

deps.yarn=[VERSIONED]
deps.yarn_mappings_neoforge_patch=[VERSIONED]

deps.architectury_api=[VERSIONED]

deps.fabric_loader=[VERSIONED]
deps.fabric_api=[VERSIONED]

deps.neoforge=[VERSIONED]

# External libraries
deps.discord4j=3.2.6
67 changes: 0 additions & 67 deletions neoforge/build.gradle

This file was deleted.

1 change: 0 additions & 1 deletion neoforge/gradle.properties

This file was deleted.

Loading

0 comments on commit 6a5863d

Please sign in to comment.