Skip to content

Commit

Permalink
Updated buildsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
Adubbz committed Nov 22, 2023
1 parent 5376348 commit 8f3044b
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 150 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish
on:
workflow_dispatch:
push:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'oracle'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Publish
run: ./gradlew publish
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
BUILD_NUMBER: ${{ github.run_number }}
- name: CurseForge Publish
run: ./gradlew curseforge -PcurseApiKey=${CURSE_API_KEY}
env:
CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }}
BUILD_NUMBER: ${{ github.run_number }}
continue-on-error: true
- name: Modrinth Publish
run: ./gradlew modrinth -PmodrinthToken=${MODRINTH_TOKEN}
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
BUILD_NUMBER: ${{ github.run_number }}
continue-on-error: true
60 changes: 0 additions & 60 deletions Jenkinsfile

This file was deleted.

168 changes: 93 additions & 75 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000"
}
}
}

plugins {
id "net.minecraftforge.gradle" version "6.0.+"
id "org.spongepowered.mixin" version "0.7-SNAPSHOT"
id "com.matthewprenger.cursegradle" version "1.4.0"
id "com.modrinth.minotaur" version "2.+"
id 'net.minecraftforge.gradleutils' version '2.2.0'
}

apply plugin: 'maven-publish'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'maven-publish'

ext {
mod_version = gradleutils.getTagOffsetVersion()
changelog_file = project.file("build/changelog.txt")
}

repositories { mavenLocal() }
changelog {
fromTag '18.2.0'
}

def trimChangelog(String text) {
def m = text =~ /(?s) - (?:[0-9.]+) (.+?)(?=( - )|$)/
return '```\n' + m[0][1].replaceAll(/(?m)^ */, '')
}

group = "com.github.glitchfiend"
archivesBaseName = "${mod_name}"
version = "${minecraft_version}-${mod_version}.${System.getenv().BUILD_NUMBER}"
def mod_build_version = "${mod_version}.${System.getenv().BUILD_NUMBER}"
base.archivesName = mod_name
version = "${minecraft_version}-${mod_version}"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.withSourcesJar()

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

// 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) {
enabled = false
}

minecraft {
mappings channel: 'official', version: minecraft_version
Expand All @@ -41,37 +50,53 @@ minecraft {
runs {
client = {
workingDirectory = project.file("run")
source sourceSets.main
ideaModule "${project.name}.main"
taskName 'Client'
mods {
modClientRun {
source sourceSets.main
}
}
}
server = {
workingDirectory = project.file("run")
source sourceSets.main
server {
workingDirectory project.file('run')
ideaModule "${project.name}.main"
taskName 'Server'
mods {
modServerRun {
source sourceSets.main
}
}
}
data {
workingDirectory = project.file("run")
source sourceSets.main
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/'), '--existing', file('src/generated/resources/')
workingDirectory project.file('run')
ideaModule "${project.name}.main"
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
taskName 'Data'
mods {
modDataRun {
source sourceSets.main
}
}
}
}
}

// Configure the source folders
sourceSets {
main {
api {
java {
srcDir "src/main/java"
compileClasspath += main.compileClasspath
srcDirs main.java.srcDirs
include "${mod_id}/api/**"
}
}
main {
resources {
srcDir "src/main/resources"
srcDir 'src/generated/resources'
}
}
}

processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

dependencies {
minecraft 'net.minecraftforge:forge:' + minecraft_version + '-' + forge_version
implementation fg.deobf("com.github.glitchfiend:TerraBlender-forge:${terrablender_version}")
Expand All @@ -82,43 +107,33 @@ jar {
attributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : mod_author,
'Specification-Version' : mod_build_version,
'Specification-Version' : mod_version,
'Implementation-Title' : project.name,
'Implementation-Version' : mod_build_version,
'Implementation-Version' : mod_version,
'Implementation-Vendor' : mod_author,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestampe' : System.currentTimeMillis(),
'Timestamp' : System.currentTimeMillis(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Build-On-Minecraft' : minecraft_version
])
}
}

task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
}

task apiJar(type: Jar) {
from(sourceSets.main.allJava) {
include "${mod_id}/api/**"
}
from (sourceSets.main.output) {
include 'LICENSE.txt'
include "${mod_id}/api/**"
}
from sourceSets.api.allJava, sourceSets.api.output
archiveClassifier = 'api'
}

// TODO: Investigate why there are duplicates produced in the first place
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
classifier = 'api'
task deobfJar(type: Jar) {
from sourceSets.main.output
archiveClassifier = 'deobf'
}

def changelog_file = rootProject.file("build/${mod_name}-${version}-changelog.txt")
build.dependsOn apiJar
build.dependsOn deobfJar

curseforge {
if (project.hasProperty('curseApiKey')) {
apiKey = project.getProperty('curseApiKey')
}
apiKey = project.findProperty('curseApiKey') ?: 'unset'
project {
id = mod_curseforge_id

Expand All @@ -135,29 +150,35 @@ curseforge {

addArtifact deobfJar
addArtifact apiJar

relations {
requiredDependency 'terrablender'
}
}
}

artifacts {
modrinth {
token = project.findProperty('modrinthToken')
projectId = mod_modrinth_id
versionNumber = mod_version
versionName = version + " for Forge " + minecraft_version
versionType = 'beta' // can be release, beta, or alpha
uploadFile = jar
gameVersions = [minecraft_version]
loaders = ['forge']

if (changelog_file.exists()) {
archives changelog_file
changelog = trimChangelog(changelog_file.text)
}
archives jar
archives deobfJar
archives apiJar
}

publishing {
publications {
mavenJava(MavenPublication) {
// We must use artifact jar to ensure the Forge dependency is excluded from the pom, breaking fg.deobf()
artifact jar
artifact deobfJar
artifact apiJar
artifact deobfJar
groupId project.group
artifactId project.archivesBaseName
version project.version
Expand Down Expand Up @@ -195,13 +216,10 @@ publishing {
}
repositories {
maven {
url "https://maven.minecraftforge.net/releases/"
authentication {
basic(BasicAuthentication)
}
url = "https://maven.minecraftforge.net/releases/"
credentials {
username = System.env.MAVEN_USER ?:'fake'
password = System.env.MAVEN_PASSWORD ?:'news'
username = System.getenv("MAVEN_USER")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

# Project
mod_version=18.1.0
mod_id=biomesoplenty
mod_name=BiomesOPlenty
mod_display_name=Biomes O' Plenty
Expand All @@ -14,6 +13,7 @@ mod_issues_url=https://github.com/Glitchfiend/BiomesOPlenty/issues
mod_git_url=https://github.com/Glitchfiend/BiomesOPlenty
mod_scm_url=scm:git:[email protected]:Glitchfiend/BiomesOPlenty.git
mod_curseforge_id=220318
mod_modrinth_id=biomes-o-plenty

# Dependencies
minecraft_version=1.20.2
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 8f3044b

Please sign in to comment.