Skip to content

Commit

Permalink
build: refactor artifacts and publications (#46)
Browse files Browse the repository at this point in the history
build: adjust shadow jar configurations

build(publish): do not publish fat-jars to maven

refactor: remove unused mixin files

build: improve fabric mod metadata

ci: add maven pom definition

ci(release): only publish packages with changes
  • Loading branch information
axieum authored Aug 1, 2022
1 parent c20b54d commit 8114fd1
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 151 deletions.
38 changes: 12 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
releases_created: ${{ steps.release-please.outputs.releases_created }}
paths_released: ${{ steps.release-please.outputs.paths_released }}
releases: ${{ toJson(steps.release-please.outputs) }}

Expand All @@ -35,7 +35,12 @@ jobs:

runs-on: ubuntu-latest
needs: release
if: ${{ needs.release.outputs.release_created }}
if: ${{ needs.release.outputs.releases_created }}

strategy:
fail-fast: false
matrix:
path: ${{ fromJson(needs.release.outputs.paths_released) }}

steps:
- name: ✨ Checkout repository
Expand All @@ -51,34 +56,15 @@ jobs:
uses: gradle/gradle-build-action@v2

- name: 📢 Publish new release
run: ./gradlew publish
uses: gradle/gradle-build-action@v2
with:
arguments: ${{ matrix.path == '.' && ':publish' || format('{0}:publish', matrix.path) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
CURSEFORGE_DEBUG: ${{ secrets.CURSEFORGE_DEBUG }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

- name: 🗃️ Archive artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: '**/build/libs/'

upload:
name: Upload

strategy:
matrix:
path: ${{ fromJson(needs.release.outputs.paths_released) }}

runs-on: ubuntu-latest
needs: [release, publish]
if: ${{ needs.release.outputs.release_created }}

steps:
- name: 🗃️ Restore artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
MODRINTH_DEBUG: ${{ secrets.MODRINTH_DEBUG }}

- name: 📦 Upload artifacts
uses: softprops/action-gh-release@v1
Expand Down
71 changes: 57 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ plugins {
id 'maven-publish'
id 'com.modrinth.minotaur' version '2.2.1'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'fabric-loom' version '0.12-SNAPSHOT'
}

allprojects {
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'fabric-loom'

group = project.maven_group
Expand All @@ -20,7 +22,7 @@ allprojects {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17

// Declare dependencies
configurations { devElements { extendsFrom implementation, namedElements } }
configurations { shade }
dependencies {
// Fabric
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -29,20 +31,11 @@ allprojects {

// Mods
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude module: 'modmenu'
}

// Code Quality
compileOnly "org.jetbrains:annotations:${project.jetbrains_annotations_version}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junit_jupiter_version}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.junit_jupiter_version}"

// Subprojects
subprojects.each {
implementation project(path: ":${it.name}", configuration: 'devElements')
include project("${it.name}:") // nest within distribution
}
}

// Perform tests using the JUnit test suite
Expand All @@ -56,6 +49,19 @@ allprojects {
// withJavadocJar()
}

// Produce a fat-jar of all shaded dependencies
shadowJar {
configurations = [project.configurations.shade]
destinationDirectory.set(layout.buildDirectory.dir('devlibs'))
}

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

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

// Add the licence to all distributions
tasks.withType(Jar).configureEach {
it.from rootProject.file('LICENCE.txt')
Expand All @@ -65,11 +71,17 @@ allprojects {
processResources {
inputs.property 'id', project.mod_id
inputs.property 'name', project.mod_name
inputs.property 'description', project.mod_description
inputs.property 'version', project.version

// fabric.mod.json
filesMatching('fabric.mod.json') {
expand(['id': project.mod_id, 'name': project.mod_name, 'version': project.version])
expand([
'id': project.mod_id,
'name': project.mod_name,
'description': project.mod_description,
'version': project.version,
])
}
}

Expand Down Expand Up @@ -101,7 +113,35 @@ allprojects {
publishing {
// Declare all publications
publications {
mavenJava(MavenPublication) { from components.java }
mavenJava(MavenPublication) {
from components.java
pom {
name = project.mod_name
description = project.mod_description
url = "https://github.com/${project.github_repo}"
licenses { license { name = 'MIT'; url = 'https://opensource.org/licenses/MIT' } }
developers {
developer {
name = 'Axieum'
email = '[email protected]'
url = 'https://github.com/axieum'
}
}
scm {
connection = "scm:git:git://github.com/${project.github_repo}.git"
developerConnection = "scm:git:ssh://[email protected]:${project.github_repo}.git"
url = "https://github.com/${project.github_repo}"
}
issueManagement { system = 'GitHub'; url = "https://github.com/${project.github_repo}/issues" }
ciManagement { system = 'GitHub'; url = "https://github.com/${project.github_repo}/actions" }
properties = [
'mod_id': project.mod_id,
'minecraft_version': project.minecraft_version,
'loader_version': project.loader_version,
'yarn_mappings': project.yarn_mappings,
]
}
}
}

// Add repositories to publish to
Expand All @@ -119,6 +159,9 @@ allprojects {
}
}

// Nest all subproject artifacts within the main/bundle distribution
dependencies { subprojects.each { include project("${it.name}:") } }

// Define how artifacts are published to CurseForge (https://curseforge.com)
curseforge {
// Set the API token from the environment
Expand Down Expand Up @@ -157,7 +200,7 @@ curseforge {
// Configure other options
options {
forgeGradleIntegration = false
debug = System.getenv('CURSEFORGE_DEBUG') as boolean ?: false
debug = (System.getenv('CURSEFORGE_DEBUG') ?: 'false').toBoolean()
}
}

Expand All @@ -167,7 +210,7 @@ modrinth {
// Set the API token from the environment
token = System.getenv('MODRINTH_TOKEN') ?: ''
// Set whether debug mode is enabled
debugMode = System.getenv('MODRINTH_DEBUG') as boolean ?: false
debugMode = (System.getenv('MODRINTH_DEBUG') ?: 'false').toBoolean()
// Set the project id
projectId = project.mr_project_id
// Set the release name
Expand Down
7 changes: 3 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Mod
mod_name = Minecord
mod_id = minecord
mod_name = Minecord
mod_description = Bring your Minecraft world into your Discord guild
## {x-release-please-start-version}
mod_version = 1.0.0-beta.3
## {x-release-please-end}
Expand All @@ -12,8 +13,6 @@ yarn_mappings = 1.19+build.1
fabric_version = 0.55.2+1.19

# Dependencies
cloth_config_version = 7.0.65

checkstyle_version = 10.3
jetbrains_annotations_version = 23.0.0
junit_jupiter_version = 5.8.2
Expand All @@ -39,4 +38,4 @@ maven_group = me.axieum.mcmod.minecord
github_repo = axieum/minecord

# Other
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx2G
45 changes: 9 additions & 36 deletions minecord-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,47 +1,20 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

apply plugin: 'com.github.johnrengelman.shadow'
configurations { shadow; implementation.extendsFrom shadow }

// Declare dependencies
dependencies {
include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}"
shadow "com.vdurmont:emoji-java:${project.emoji_java_version}"
shadow("net.dv8tion:JDA:${project.jda_version}") {
modApi include("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude module: 'modmenu'
}
implementation shade("com.vdurmont:emoji-java:${project.emoji_java_version}")
implementation shade("net.dv8tion:JDA:${project.jda_version}") {
exclude module: 'opus-java' // exclude audio
}
shadow("org.apache.logging.log4j:log4j-slf4j18-impl:${project.log4j_version}") {
implementation shade("org.apache.logging.log4j:log4j-slf4j18-impl:${project.log4j_version}") {
exclude module: 'log4j-api' // exclude log4j itself, we transitively use via Minecraft
exclude module: 'log4j-core'
}
}

// Produce a fat-jar of all the shaded dependencies
// Configure the fat-jar of shaded dependencies
shadowJar {
archiveClassifier.set('dev')
configurations = [project.configurations.shadow]

// Relocate dependencies
final dest = "${project.group}.shadow.api"
// relocate 'club.minnced.opus', "${dest}.club.minnced.opus"
relocate 'com.fasterxml.jackson', "${dest}.com.fasterxml.jackson"
relocate 'com.iwebpp.crypto', "${dest}.com.iwebpp.crypto"
relocate 'com.neovisionaries.ws', "${dest}.com.neovisionaries.ws"
// relocate 'com.sun.jna', "${dest}.com.sun.jna"
// relocate 'com.vdurmont.emoji', "${dest}.com.vdurmont.emoji"
relocate 'gnu.trove', "${dest}.gnu.trove"
relocate 'javax.annotation', "${dest}.javax.annotation"
// relocate 'net.dv8tion.jda', "${dest}.net.dv8tion.jda"
relocate 'okhttp3', "${dest}.okhttp3"
relocate 'okio', "${dest}.okio"
relocate 'org.jetbrains.annotations', "${dest}.org.jetbrains.annotations"
// relocate 'tomp2p.opuswrapper', "${dest}.tomp2p.opuswrapper"
}

// Provide the fat-jar to Fabric's remapping task
remapJar {
dependsOn tasks.shadowJar
inputFile.set(tasks.shadowJar.archiveFile)
// Relocate problematic dependencies
relocate 'kotlin', "${project.group}.shadow.kotlin"
}
4 changes: 3 additions & 1 deletion minecord-api/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Mod
mod_name = Minecord API
mod_id = minecord-api
mod_name = Minecord API
mod_description = Equips developers with the tools necessary to integrate their mods with Discord
## {x-release-please-start-version}
mod_version = 1.0.0-beta.3
## {x-release-please-end}

# Dependencies
cloth_config_version = 7.0.65
emoji_java_version = 5.1.1
jda_version = 5.0.0-alpha.12
log4j_version = 2.17.2
14 changes: 10 additions & 4 deletions minecord-api/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
"id": "${id}",
"version": "${version}",
"name": "${name}",
"description": "Equips developers with the tools necessary to integrate their mods with Discord",
"authors": [
"Axieum"
],
"description": "${description}",
"contact": {
"homepage": "https://github.com/axieum/minecord",
"sources": "https://github.com/axieum/minecord",
"issues": "https://github.com/axieum/minecord/issues",
"wiki": "https://github.com/axieum/minecord/wiki"
},
"authors": [
{
"name": "Axieum",
"contact": {
"email": "[email protected]",
"homepage": "https://github.com/axieum"
}
}
],
"license": "MIT",
"icon": "assets/minecord-api/icon.png",
"environment": "server",
Expand Down
22 changes: 2 additions & 20 deletions minecord-chat/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

apply plugin: 'com.github.johnrengelman.shadow'
configurations { shadow; implementation.extendsFrom shadow }

// Declare dependencies
dependencies {
implementation project(path: ':minecord-api', configuration: 'shadow')
shadow "io.github.java-diff-utils:java-diff-utils:${project.java_diff_utils_version}"
}

// Produce a fat-jar of all the shaded dependencies
shadowJar {
archiveClassifier.set('dev')
configurations = [project.configurations.shadow]
}

// Provide the fat-jar to Fabric's remapping task
remapJar {
dependsOn tasks.shadowJar
inputFile.set(tasks.shadowJar.archiveFile)
implementation project(path: ':minecord-api', configuration: 'namedElements')
implementation shade("io.github.java-diff-utils:java-diff-utils:${project.java_diff_utils_version}")
}
3 changes: 2 additions & 1 deletion minecord-chat/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Mod
mod_name = Minecord Chat
mod_id = minecord-chat
mod_name = Minecord Chat
mod_description = Bridges chat-related events between Minecraft and Discord
## {x-release-please-start-version}
mod_version = 1.0.0-beta.3
## {x-release-please-end}
Expand Down
14 changes: 10 additions & 4 deletions minecord-chat/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
"id": "${id}",
"version": "${version}",
"name": "${name}",
"description": "Bridges chat-related events between Minecraft and Discord",
"authors": [
"Axieum"
],
"description": "${description}",
"contact": {
"homepage": "https://github.com/axieum/minecord",
"sources": "https://github.com/axieum/minecord",
"issues": "https://github.com/axieum/minecord/issues",
"wiki": "https://github.com/axieum/minecord/wiki"
},
"authors": [
{
"name": "Axieum",
"contact": {
"email": "[email protected]",
"homepage": "https://github.com/axieum"
}
}
],
"license": "MIT",
"icon": "assets/minecord-chat/icon.png",
"environment": "server",
Expand Down
Loading

0 comments on commit 8114fd1

Please sign in to comment.