Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Publishing to Maven repos and access wideners #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ architectury.common(stonecutter.tree.branches.mapNotNull {
else it.prop("loom.platform")
})

dependencies {
minecraft("com.mojang:minecraft:$minecraft")
mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2")
modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}")
"io.github.llamalad7:mixinextras-common:${mod.dep("mixin_extras")}".let {
annotationProcessor(it)
implementation(it)
}
}

loom {
accessWidenerPath = rootProject.file("src/main/resources/template.accesswidener")

Expand All @@ -35,6 +25,16 @@ loom {
}
}

dependencies {
minecraft("com.mojang:minecraft:$minecraft")
mappings("net.fabricmc:yarn:$minecraft+build.${mod.dep("yarn_build")}:v2")
modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}")
"io.github.llamalad7:mixinextras-common:${mod.dep("mixin_extras")}".let {
annotationProcessor(it)
implementation(it)
}
}

java {
withSourcesJar()
val java = if (stonecutter.eval(minecraft, ">=1.20.5"))
Expand All @@ -46,4 +46,4 @@ java {
tasks.build {
group = "versioned"
description = "Must run through 'chiseledBuild'"
}
}
45 changes: 30 additions & 15 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


plugins {
`maven-publish`
id("dev.architectury.loom")
id("architectury-plugin")
id("com.github.johnrengelman.shadow")
Expand Down Expand Up @@ -38,29 +39,32 @@ configurations {
get("developmentFabric").extendsFrom(commonBundle)
}

dependencies {
minecraft("com.mojang:minecraft:$minecraft")
mappings("net.fabricmc:yarn:$minecraft+build.${common.mod.dep("yarn_build")}:v2")
modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}")

commonBundle(project(common.path, "namedElements")) { isTransitive = false }
shadowBundle(project(common.path, "transformProductionFabric")) { isTransitive = false }
}

loom {
decompilers {
get("vineflower").apply { // Adds names to lambdas - useful for mixins
options.put("mark-corresponding-synthetics", "1")
}
}

accessWidenerPath = common.loom.accessWidenerPath

runConfigs.all {
isIdeConfigGenerated = true
runDir = "../../../run"
vmArgs("-Dmixin.debug.export=true")
}
}

dependencies {
minecraft("com.mojang:minecraft:$minecraft")
mappings("net.fabricmc:yarn:$minecraft+build.${common.mod.dep("yarn_build")}:v2")
modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}")

commonBundle(project(common.path, "namedElements")) { isTransitive = false }
shadowBundle(project(common.path, "transformProductionFabric")) { isTransitive = false }
}


java {
withSourcesJar()
val java = if (stonecutter.eval(minecraft, ">=1.20.5"))
Expand All @@ -69,9 +73,19 @@ java {
sourceCompatibility = java
}

tasks.shadowJar {
configurations = listOf(shadowBundle)
archiveClassifier = "dev-shadow"
publishing {
publications {
create<MavenPublication>("mod") {
artifact(tasks.remapJar)
artifact(tasks.remapSourcesJar)
artifactId = mod.id
group = mod.group
}
}
}

tasks.jar {
archiveClassifier = "dev"
}

tasks.remapJar {
Expand All @@ -81,8 +95,9 @@ tasks.remapJar {
dependsOn(tasks.shadowJar)
}

tasks.jar {
archiveClassifier = "dev"
tasks.shadowJar {
configurations = listOf(shadowBundle)
archiveClassifier = "dev-shadow"
}

tasks.processResources {
Expand All @@ -105,4 +120,4 @@ tasks.register<Copy>("buildAndCollect") {
from(tasks.remapJar.get().archiveFile, tasks.remapSourcesJar.get().archiveFile)
into(rootProject.layout.buildDirectory.file("libs/${mod.version}/$loader"))
dependsOn("build")
}
}
47 changes: 30 additions & 17 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:Suppress("UnstableApiUsage")

plugins {
`maven-publish`
id("dev.architectury.loom")
id("architectury-plugin")
id("com.github.johnrengelman.shadow")
Expand Down Expand Up @@ -37,29 +38,13 @@ configurations {
get("developmentForge").extendsFrom(commonBundle)
}

repositories {
maven("https://maven.minecraftforge.net")
}

dependencies {
minecraft("com.mojang:minecraft:$minecraft")
mappings("net.fabricmc:yarn:$minecraft+build.${common.mod.dep("yarn_build")}:v2")
"forge"("net.minecraftforge:forge:$minecraft-${common.mod.dep("forge_loader")}")
"io.github.llamalad7:mixinextras-forge:${mod.dep("mixin_extras")}".let {
implementation(it)
include(it)
}

commonBundle(project(common.path, "namedElements")) { isTransitive = false }
shadowBundle(project(common.path, "transformProductionForge")) { isTransitive = false }
}

loom {
decompilers {
get("vineflower").apply { // Adds names to lambdas - useful for mixins
options.put("mark-corresponding-synthetics", "1")
}
}
accessWidenerPath = common.loom.accessWidenerPath

forge.convertAccessWideners = true
forge.mixinConfigs(
Expand All @@ -74,6 +59,23 @@ loom {
}
}

repositories {
maven("https://maven.minecraftforge.net")
}

dependencies {
minecraft("com.mojang:minecraft:$minecraft")
mappings("net.fabricmc:yarn:$minecraft+build.${common.mod.dep("yarn_build")}:v2")
"forge"("net.minecraftforge:forge:$minecraft-${common.mod.dep("forge_loader")}")
"io.github.llamalad7:mixinextras-forge:${mod.dep("mixin_extras")}".let {
implementation(it)
include(it)
}

commonBundle(project(common.path, "namedElements")) { isTransitive = false }
shadowBundle(project(common.path, "transformProductionForge")) { isTransitive = false }
}

java {
withSourcesJar()
val java = if (stonecutter.eval(minecraft, ">=1.20.5"))
Expand All @@ -82,6 +84,17 @@ java {
sourceCompatibility = java
}

publishing {
publications {
create<MavenPublication>("mod") {
artifact(tasks.remapJar)
artifact(tasks.remapSourcesJar)
artifactId = mod.id
group = mod.group
}
}
}

tasks.jar {
archiveClassifier = "dev"
}
Expand Down
42 changes: 28 additions & 14 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:Suppress("UnstableApiUsage")

plugins {
`maven-publish`
id("dev.architectury.loom")
id("architectury-plugin")
id("com.github.johnrengelman.shadow")
Expand Down Expand Up @@ -37,6 +38,22 @@ configurations {
get("developmentNeoForge").extendsFrom(commonBundle)
}

loom {
decompilers {
get("vineflower").apply { // Adds names to lambdas - useful for mixins
options.put("mark-corresponding-synthetics", "1")
}
}

accessWidenerPath = common.loom.accessWidenerPath

runConfigs.all {
isIdeConfigGenerated = true
runDir = "../../../run"
vmArgs("-Dmixin.debug.export=true")
}
}

repositories {
maven("https://maven.neoforged.net/releases/")
}
Expand All @@ -59,20 +76,6 @@ dependencies {
shadowBundle(project(common.path, "transformProductionNeoForge")) { isTransitive = false }
}

loom {
decompilers {
get("vineflower").apply { // Adds names to lambdas - useful for mixins
options.put("mark-corresponding-synthetics", "1")
}
}

runConfigs.all {
isIdeConfigGenerated = true
runDir = "../../../run"
vmArgs("-Dmixin.debug.export=true")
}
}

java {
withSourcesJar()
val java = if (stonecutter.eval(minecraft, ">=1.20.5"))
Expand All @@ -81,6 +84,17 @@ java {
sourceCompatibility = java
}

publishing {
publications {
create<MavenPublication>("mod") {
artifact(tasks.remapJar)
artifact(tasks.remapSourcesJar)
artifactId = mod.id
group = mod.group
}
}
}

tasks.jar {
archiveClassifier = "dev"
}
Expand Down
35 changes: 34 additions & 1 deletion stonecutter.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
`maven-publish`
id("dev.kikugie.stonecutter")
id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false
id("architectury-plugin") version "3.4-SNAPSHOT" apply false
Expand All @@ -13,15 +14,28 @@ stonecutter registerChiseled tasks.register("chiseledBuild", stonecutter.chisele
ofTask("buildAndCollect")
}

// Builds loader-specific versions into `build/libs/{mod.version}/{loader}`
stonecutter registerChiseled tasks.register("chiseledPublish", stonecutter.chiseled) {
group = "project"
ofTask("publish")
}

for (it in stonecutter.tree.branches) {
if (it.id.isEmpty()) continue
val loader = it.id.upperCaseFirst()

// Builds loader-specific versions into `build/libs/{mod.version}/{loader}`
stonecutter registerChiseled tasks.register("chiseledBuild$loader", stonecutter.chiseled) {
group = "project"
versions { branch, _ -> branch == it.id }
ofTask("buildAndCollect")
}

// Publishes loader-specific versions
stonecutter registerChiseled tasks.register("chiseledPublish$loader", stonecutter.chiseled) {
group = "project"
versions { branch, _ -> branch == it.id }
ofTask("publish")
}
}

// Runs active versions for each loader
Expand All @@ -34,3 +48,22 @@ for (it in stonecutter.tree.nodes) {
dependsOn("run$type")
}
}

subprojects {
apply {
plugin("maven-publish")
plugin("java")
}

repositories {
mavenCentral()
// define repositories used by all projects here
}

publishing {
repositories {
// define your publishing repositories here
mavenLocal()
}
}
}