Skip to content

Commit

Permalink
Mod platform publishing task (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
hashalite authored Feb 4, 2024
2 parents d748328 + bad3588 commit 00ec7da
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 58 deletions.
133 changes: 102 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import net.fabricmc.loom.task.RemapJarTask
import org.jetbrains.changelog.Changelog

plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "com.hypherionmc.modutils.modpublisher" version "2.0.5" apply false
id "com.github.johnrengelman.shadow" version "7.1.2" apply false
id "org.jetbrains.changelog" version "2.2.0"
}
Expand Down Expand Up @@ -52,37 +56,6 @@ changelog {
headerParserRegex = ~/(\d+(?:\.\d+)+)/
}

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

loom {
accessWidenerPath = project(":common").file "src/main/resources/freecam.accesswidener"

runs {
client {
// Pretty run-config name
// Note: we can't disable the (:path) suffix
// https://github.com/architectury/architectury-loom/blob/5b3e7c72b665f7eb38c23ceb677027acdc867398/src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java#L117
configName "Run"
}
remove server // We only need client runs
}

silentMojangMappingsLicense()
}

dependencies {
def parchmentAppendix = rootProject.parchment_version.split('-')[0]
def parchmentVersion = rootProject.parchment_version.split('-')[1]

minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${parchmentAppendix}:${parchmentVersion}@zip")
}
}
}

allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
Expand Down Expand Up @@ -127,3 +100,101 @@ allprojects {
from "LICENSE"
}
}

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

loom {
accessWidenerPath = project(":common").file "src/main/resources/freecam.accesswidener"

runs {
client {
// Pretty run-config name
// Note: we can't disable the (:path) suffix
// https://github.com/architectury/architectury-loom/blob/5b3e7c72b665f7eb38c23ceb677027acdc867398/src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java#L117
configName "Run"
}
remove server // We only need client runs
}

silentMojangMappingsLicense()
}

dependencies {
def parchmentAppendix = rootProject.parchment_version.split('-')[0]
def parchmentVersion = rootProject.parchment_version.split('-')[1]

minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${parchmentAppendix}:${parchmentVersion}@zip")
}
}

if (rootProject.enabled_platforms.split(',').contains project.name) {
apply plugin: "com.hypherionmc.modutils.modpublisher"

// Ensure this task exists, since we need to publish its output
tasks.maybeCreate("remapModrinthJar", RemapJarTask)

publisher {
curseID = "557076"
modrinthID = "XeEZ3fK2"

// Format display name "[Fabric] Freecam 1.2.2 for MC 1.20.4"
displayName = "[${project.name.capitalize()}] ${rootProject.name.capitalize()} ${rootProject.mod_version} for MC ${rootProject.minecraft_version}"
version = project.version
versionType = rootProject.release_type
curseEnvironment = "client"
loaders = [ project.name ]

// Get the changelog entry using the changelog plugin
changelog = provider {
def plugin = rootProject.changelog
def version = rootProject.mod_version
if (!plugin.has(version)) {
logger.warn "No changelog for \"${version}\". Using \"unreleased\" instead."
}

def logEntry = (plugin.getOrNull(version) ?: plugin.getUnreleased())
.withHeader(false)
.withLinks(false)
.withEmptySections(false)
.withSummary(true)

return plugin.renderItem(logEntry, Changelog.OutputType.MARKDOWN)
}

// List the current `minecraft_version`, everything in `supported_mc_versions`, &
// everything in the current mod loader's `*_supported_mc_versions` as a supported version
gameVersions = provider {
String prop = "supported_mc_versions"
String primary = rootProject.property("minecraft_version")
String common = rootProject.findProperty(prop) ?: ""
String specific = rootProject.findProperty("${project.name}_${prop}") ?: ""

return (common.split(",") + specific.split(",") + [ primary ])
.findAll { it != null }
.findAll { it != "" }
.collect { it.trim() }
.unique()
}

artifact = tasks.remapJar
setPlatformArtifact "modrinth", tasks.remapModrinthJar

[ curseDepends, modrinthDepends ].each {
it.embedded "cloth-config"
}

def dummy = "default"
apiKeys {
curseforge findProperty("curseforge_token") ?: System.getenv("CURSEFORGE_TOKEN") ?: dummy
modrinth findProperty("modrinth_token") ?: System.getenv("MODRINTH_TOKEN") ?: dummy
}
debug = [ apiKeys.curseforge, apiKeys.modrinth ].contains dummy
}

tasks.publish.dependsOn tasks.publishMod
}
}
19 changes: 7 additions & 12 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import net.fabricmc.loom.task.RemapJarTask

plugins {
id "com.github.johnrengelman.shadow"
id "com.hypherionmc.modutils.modpublisher"
}

def variants = rootProject.build_variants.split(',')
Expand Down Expand Up @@ -80,8 +81,8 @@ variants.each { variant ->
remapJarTask = tasks.remapJar
appendix = ""
} else {
shadowJarTask = tasks.create("shadow${variant.capitalize()}Jar", ShadowJar)
remapJarTask = tasks.create("remap${variant.capitalize()}Jar", RemapJarTask)
shadowJarTask = tasks.maybeCreate("shadow${variant.capitalize()}Jar", ShadowJar)
remapJarTask = tasks.maybeCreate("remap${variant.capitalize()}Jar", RemapJarTask)
appendix = variant
}

Expand Down Expand Up @@ -123,15 +124,9 @@ components.java {
}
}

publishing {
publications {
mavenFabric(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
publisher {
[ curseDepends, modrinthDepends ].each {
it.required "fabric-api"
it.optional "modmenu"
}
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ source_code_url=https://github.com/MinecraftFreecam/Freecam
issue_tracker_url=https://github.com/MinecraftFreecam/Freecam/issues
enabled_platforms=fabric,neoforge
build_variants=normal,modrinth
# release, beta or alpha. Used for publishMod task.
release_type=release

# Check versions on:
# https://discord.architectury.dev
Expand All @@ -22,16 +24,19 @@ build_variants=normal,modrinth
# https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
minecraft_version=1.20.4
parchment_version=1.20.2-2023.12.10
supported_mc_versions=

fabric_loader_version=0.15.3
fabric_api_version=0.91.2+1.20.4
fabric_loader_req=>=0.12.11
fabric_mc_req=~1.20.4
fabric_supported_mc_versions=

neoforge_version=20.4.60-beta
neoforge_mc_req=[1.20.4,)
neoforge_loader_req=[1,)
neoforge_req=[20,)
neoforge_supported_mc_versions=

# Other dependencies
# https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu
Expand Down
17 changes: 2 additions & 15 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ variants.each { variant ->
remapJarTask = tasks.remapJar
appendix = ""
} else {
shadowJarTask = tasks.create("shadow${variant.capitalize()}Jar", ShadowJar)
remapJarTask = tasks.create("remap${variant.capitalize()}Jar", RemapJarTask)
shadowJarTask = tasks.maybeCreate("shadow${variant.capitalize()}Jar", ShadowJar)
remapJarTask = tasks.maybeCreate("remap${variant.capitalize()}Jar", RemapJarTask)
appendix = variant
}

Expand Down Expand Up @@ -128,16 +128,3 @@ components.java {
skip()
}
}

publishing {
publications {
mavenForge(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pluginManagement {
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.architectury.dev/" }
maven { url "https://maven.minecraftforge.net/" }
maven { url "https://maven.firstdark.dev/releases/" }
gradlePluginPortal()
}
}
Expand Down

0 comments on commit 00ec7da

Please sign in to comment.