Skip to content

Commit

Permalink
Update setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrbysco committed Sep 28, 2024
1 parent b01e5e6 commit 363ad4e
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 99 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
Expand All @@ -17,14 +17,19 @@ jobs:
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ForgeArtifact
path: ./Forge/build/libs/*.jar
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: FabricArtifact
path: ./Fabric/build/libs/*.jar
- name: Publish to maven
if: contains(github.event.head_commit.message, '[push]') || contains(github.event.head_commit.message, '[build]')
env:
SAP_SECRET: ${{ secrets.SAP_SECRET }}
run: ./gradlew publish
- name: Publish To Curseforge
if: contains(github.event.head_commit.message, '[publish]') || contains(github.event.head_commit.message, '[curseforge]')
env:
Expand All @@ -34,9 +39,4 @@ jobs:
if: contains(github.event.head_commit.message, '[publish]') || contains(github.event.head_commit.message, '[modrinth]')
env:
MODRINTH_KEY: ${{ secrets.MODRINTH_KEY }}
run: ./gradlew modrinth
- name: Publish to maven
if: contains(github.event.head_commit.message, '[push]') || contains(github.event.head_commit.message, '[build]')
env:
SAP_SECRET: ${{ secrets.SAP_SECRET }}
run: ./gradlew publish
run: ./gradlew modrinth
32 changes: 11 additions & 21 deletions Common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
plugins {
id 'idea'
id 'java'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
id 'maven-publish'
id 'org.spongepowered.gradle.vanilla'
}

archivesBaseName = "${mod_name}-common-${minecraft_version}"
base {
archivesName = "${mod_name}-common-${minecraft_version}"
}

minecraft {
version(minecraft_version)
runs {
if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) {

server(project.hasProperty('common_server_run_name') ? project.findProperty('common_server_run_name') : 'vanilla_server') {
workingDirectory(this.file("run"))
}
client(project.hasProperty('common_client_run_name') ? project.findProperty('common_client_run_name') : 'vanilla_client') {
workingDirectory(this.file("run"))
}
}
if (file("src/main/resources/${mod_id}.accesswidener").exists()) {
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
}
}

dependencies {
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.4'
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
}

processResources {
def buildProps = project.properties.clone()
filesMatching(['pack.mcmeta']) {
expand buildProps
}
}

publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
artifactId base.archivesName.get()
version project.version
artifact jar
from components.java
}
}
repositories {
Expand Down
41 changes: 26 additions & 15 deletions Fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'maven-publish'
id 'java'
id 'idea'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.modrinth.minotaur' version "2.+"
id 'maven-publish'
id 'fabric-loom'
id 'com.matthewprenger.cursegradle'
id 'com.modrinth.minotaur'
}

archivesBaseName = "${mod_name}-fabric-${minecraft_version}"
base {
archivesName = "${mod_name}-fabric-${minecraft_version}"
}

repositories {
maven {
Expand All @@ -25,7 +28,7 @@ dependencies {
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
implementation project(":Common")
implementation project(":common")

modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
Expand All @@ -34,6 +37,13 @@ dependencies {
}

loom {
if (project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()) {
accessWidenerPath.set(project(":common").file("src/main/resources/${mod_id}.accesswidener"))
}

mixin {
defaultRefmapName.set("${mod_id}.refmap.json")
}
runs {
client {
client()
Expand All @@ -51,17 +61,18 @@ loom {
}


processResources {
from project(":Common").sourceSets.main.resources
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).configureEach {
source(project(":common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}

tasks.withType(JavaCompile) {
source(project(":Common").sourceSets.main.allSource)
processResources {
from project(":common").sourceSets.main.resources
}

publishing {
Expand Down
62 changes: 38 additions & 24 deletions Forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
buildscript {
repositories {
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
plugins {
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.modrinth.minotaur' version "2.+"
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle'
id 'org.spongepowered.mixin'
id 'com.matthewprenger.cursegradle'
id 'com.modrinth.minotaur'
}

base {
archivesName = "${mod_name}-forge-${minecraft_version}"
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'maven-publish'

archivesBaseName = "${mod_name}-forge-${minecraft_version}"
mixin {
add(sourceSets.main, "${mod_id}.refmap.json")

config("${mod_id}.forge.mixins.json")
}

minecraft {
mappings channel: 'official', version: minecraft_version
Expand All @@ -34,10 +32,13 @@ minecraft {
workingDirectory project.file('run')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Client'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
jvmArgs("-Xmx4G")
mods {
modClientRun {
source sourceSets.main
source project(":Common").sourceSets.main
source project(":common").sourceSets.main
}
}
}
Expand All @@ -46,10 +47,13 @@ minecraft {
workingDirectory project.file('run')
ideaModule "${rootProject.name}.${project.name}.main"
taskName 'Server'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
jvmArgs("-Xmx4G")
mods {
modServerRun {
source sourceSets.main
source project(":Common").sourceSets.main
source project(":common").sourceSets.main
}
}
}
Expand All @@ -59,10 +63,13 @@ minecraft {
ideaModule "${rootProject.name}.${project.name}.main"
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
taskName 'Data'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
jvmArgs("-Xmx4G")
mods {
modDataRun {
source sourceSets.main
source project(":Common").sourceSets.main
source project(":common").sourceSets.main
}
}
}
Expand All @@ -73,15 +80,22 @@ sourceSets.main.resources.srcDir 'src/generated/resources'

dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
compileOnly project(":Common")
annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor")
compileOnly project(":common")
}

tasks.withType(JavaCompile) {
source(project(":Common").sourceSets.main.allSource)
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.allSource)
}
tasks.withType(Javadoc).configureEach {
source(project(":common").sourceSets.main.allJava)
}
tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}

processResources {
from project(":Common").sourceSets.main.resources
from project(":common").sourceSets.main.resources
}

jar.finalizedBy('reobfJar')
Expand Down
21 changes: 18 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT' apply(false)
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false)
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false)
id("org.spongepowered.mixin") version "0.7-SNAPSHOT" apply(false)
id("com.matthewprenger.cursegradle") version "1.4.0" apply(false)
id("com.modrinth.minotaur") version "2.+" apply(false)
}

subprojects {
apply plugin: 'java'

Expand Down Expand Up @@ -40,13 +49,19 @@ subprojects {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release = 17
it.options.getRelease().set(17)
}

processResources {
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'mods.toml', '*.mixins.json']) {
expand project.properties
}
}

// Disables Gradle's custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
tasks.withType(GenerateModuleMetadata) {
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 363ad4e

Please sign in to comment.