Skip to content

Commit

Permalink
feat: port to 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Dec 26, 2023
1 parent 7d0d457 commit 69a1a48
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 79 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ jobs:
build:
if: |
!contains(github.event.head_commit.message, '[ciskip]')
uses: nanite/workflows/.github/workflows/standard-arch-release.yml@v1
uses: nanite/workflows/.github/workflows/[email protected]
with:
gradle-tasks: 'build publish publishMods'
secrets:
nanite-token: ${{ secrets.NANITE_DEPLOY }}
curse-token: ${{ secrets.CURSE_DEPLOY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## [81.1.0]
## [82.0.0]

### Changed

- Ported to 1.20.1
- Ported to 1.20.2
97 changes: 94 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false
id "architectury-plugin" version "3.4.151"
id "dev.architectury.loom" version "1.4.373" apply false
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
}

architectury {
Expand Down Expand Up @@ -51,6 +52,96 @@ allprojects {
java {
withSourcesJar()
}

publishing {
repositories {
if (ENV.NANITE_TOKEN) {
maven {
url "https://maven.nanite.dev/releases"
credentials {
username = "nanite"
password = "${ENV.NANITE_TOKEN}"
}
}
}
}
}
}

task curseforgePublish
publishMods {
dryRun = providers.environmentVariable("CURSE_TOKEN").getOrNull() == null
changelog = file("./CHANGELOG.md").text
version = "${mod_version}"
type = STABLE

def fabricOptions = publishOptions {
file = project.provider { project(":fabric").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "[FABRIC][${minecraft_version}] Default Server Properties ${mod_version}"
modLoaders.add("fabric")
}

def forgeOptions = publishOptions {
file = project.provider { project(":forge").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "[FORGE][${minecraft_version}] Default Server Properties ${mod_version}"
modLoaders.add("forge")
}

def neoForge = publishOptions {
file = project.provider { project(":neoforge").tasks.remapJar }.flatMap { it.archiveFile }
displayName = "[NEOFORGE][${minecraft_version}] Default Server Properties ${mod_version}"
modLoaders.add("neoforge")
}

def curseForgeOptions = curseforgeOptions {
accessToken = providers.environmentVariable("CURSE_TOKEN")
projectId = "${curseforge_id}"
minecraftVersions.add("${minecraft_version}")
}

def modrinthOptions = modrinthOptions {
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
projectId = "${modrinth_id}"
minecraftVersions.add("${minecraft_version}")
}

curseforge("curseforgeFabric") {
from(curseForgeOptions, fabricOptions)
requires {
slug = "fabric-api"
}
}

curseforge("curseforgeForge") {
from(curseForgeOptions, forgeOptions)
}

curseforge("curseforgeNeoForge") {
from(curseForgeOptions, neoForge)
}

modrinth("modrinthFabric") {
from(modrinthOptions, fabricOptions)
requires {
slug = "fabric-api"
}
}

modrinth("modrinthForge") {
from(modrinthOptions, forgeOptions)
}

modrinth("modrinthNeoforge") {
from(modrinthOptions, neoForge)
}

github {
file = project.provider { project(":forge").tasks.remapJar }.flatMap { it.archiveFile }
additionalFiles.from project.provider { project(":fabric").tasks.remapJar }.flatMap { it.archiveFile }
additionalFiles.from project.provider { project(":neoforge").tasks.remapJar }.flatMap { it.archiveFile }

repository = "${project.github_repo}"
accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = providers.environmentVariable("GITHUB_SHA").orElse("dryRun")
tagName = providers.environmentVariable("GITHUB_REF_NAME").orElse("dryRun")
}
}
31 changes: 0 additions & 31 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.matthewprenger.cursegradle" version "1.4.0"
}

architectury {
Expand Down Expand Up @@ -78,34 +77,4 @@ publishing {
from components.java
}
}

repositories {
if (ENV.NANITE_TOKEN) {
maven {
url "https://maven.nanite.dev/releases"
credentials {
username = "nanite"
password = "${ENV.NANITE_TOKEN}"
}
}
}
}
}

if (ENV.CURSE_TOKEN) {
curseforge {
apiKey = ENV.CURSE_TOKEN
project {
id = rootProject.curseforge_id
releaseType = "beta"
addGameVersion "Fabric"
addGameVersion "Java 17"
addGameVersion "${rootProject.minecraft_version}"
mainArtifact(remapJar.getArchiveFile())
changelog = file("./../CHANGELOG.md")
changelogType = 'markdown'
}
}
}

rootProject.tasks.getByName("curseforgePublish").dependsOn tasks.getByName("curseforge")
33 changes: 1 addition & 32 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.matthewprenger.cursegradle" version "1.4.0"
}

architectury {
Expand Down Expand Up @@ -29,7 +28,7 @@ configurations {
}

dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
Expand Down Expand Up @@ -88,34 +87,4 @@ publishing {
from components.java
}
}

repositories {
if (ENV.NANITE_TOKEN) {
maven {
url "https://maven.nanite.dev/releases"
credentials {
username = "nanite"
password = "${ENV.NANITE_TOKEN}"
}
}
}
}
}

if (ENV.CURSE_TOKEN) {
curseforge {
apiKey = ENV.CURSE_TOKEN
project {
id = rootProject.curseforge_id
releaseType = "release"
addGameVersion "Forge"
addGameVersion "Java 17"
addGameVersion "${rootProject.minecraft_version}"
mainArtifact(remapJar.getArchiveFile())
changelog = file("./../CHANGELOG.md")
changelogType = 'markdown'
}
}
}

rootProject.tasks.getByName("curseforgePublish").dependsOn tasks.getByName("curseforge")
16 changes: 10 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
org.gradle.jvmargs=-Xmx2048M

minecraft_version=1.20.1
enabled_platforms=fabric,forge
minecraft_version=1.20.2
enabled_platforms=fabric,forge,neoforge

archives_base_name=default-server-properties
mod_version=81.1.0
mod_version=82.0.0
maven_group=dev.nanite.mods

fabric_loader_version=0.14.21
fabric_api_version=0.83.1+1.20.1
fabric_loader_version=0.15.3
fabric_api_version=0.91.2+1.20.2

forge_version=1.20.1-47.0.6
forge_version=48.1.0
neo_forge=20.2.86

curseforge_id=676811
modrinth_id=Fnrzx9Jl
github_repo=nanite/Default-Server-Properties

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
92 changes: 92 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}

architectury {
platformSetupLoomIde()
neoForge()
}

repositories {
maven {
url "https://maven.saps.dev/mirror"
}
}

loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
neoForge {

}
}

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentNeoForge.extendsFrom common
}

dependencies {
neoForge "net.neoforged:neoforge:${rootProject.neo_forge}"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }
}

processResources {
def forgeMajor = ((String) rootProject.forge_version).split("-").last().split("\\.").first()
inputs.properties([
version: project.version,
mcversion: rootProject.minecraft_version,
forgemajor: forgeMajor
])

filesMatching("META-INF/mods.toml") {
expand "version": project.version,
"mcversion": rootProject.minecraft_version,
"forgemajor": forgeMajor
}
}

shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
setArchiveClassifier("dev-shadow")
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveBaseName.set "${rootProject.archives_base_name}-${project.name}"
setArchiveClassifier(null)
atAccessWideners.add('dsp.accesswidener')
}

jar {
setArchiveClassifier("dev")
}

sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}

components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}

publishing {
publications {
mavenNeoForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
}
1 change: 1 addition & 0 deletions neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=neoforge
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.nanite.dsp.neoforge;

import net.neoforged.fml.loading.FMLPaths;

import java.nio.file.Path;

public class DSPExpectedPlatformImpl {
public static Path getGameDir() {
return FMLPaths.GAMEDIR.get();
}
}
11 changes: 11 additions & 0 deletions neoforge/src/main/java/dev/nanite/dsp/neoforge/DSPModNeoforge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.nanite.dsp.neoforge;

import dev.nanite.dsp.DSPMod;
import net.neoforged.fml.common.Mod;

@Mod(DSPMod.MOD_ID)
public class DSPModNeoforge {
public DSPModNeoforge() {
DSPMod.init();
}
}
Loading

0 comments on commit 69a1a48

Please sign in to comment.