Update build system

This commit is contained in:
zontreck 2024-09-14 14:49:34 -07:00
parent b005eeb0fc
commit 6cec3dcbbc
8 changed files with 172 additions and 67 deletions

51
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,51 @@
pipeline {
agent any
options {
buildDiscarder(
logRotator(
numToKeepStr: '5'
)
)
}
stages {
stage("Build on Linux") {
agent {
label 'linux'
}
tools {
jdk "jdk17"
}
steps {
script {
sh '''
#!/bin/bash
git clean -xfd
git reset --hard
git fetch
export JAVA_OPTS=-Dfile.encoding=UTF-8
java -version
chmod +x gradlew
./gradlew -Dorg.gradle.java.home="$JAVA_HOME" build publish
'''
}
}
post {
always {
archiveArtifacts artifacts: "build/libs/*.jar"
deleteDir()
}
}
}
}
}

View file

@ -2,7 +2,8 @@ plugins {
id 'eclipse' id 'eclipse'
id 'idea' id 'idea'
id 'maven-publish' id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1+' id 'java-library'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'org.parchmentmc.librarian.forgegradle' version '1.+' id 'org.parchmentmc.librarian.forgegradle' version '1.+'
} }
@ -13,6 +14,17 @@ base {
archivesName = mod_id archivesName = mod_id
} }
java {
withSourcesJar()
withJavadocJar()
}
configurations {
provided
compile.extendsFrom(provided)
}
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17) java.toolchain.languageVersion = JavaLanguageVersion.of(17)
@ -27,11 +39,11 @@ minecraft {
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
// //
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started // Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started
// //
// Use non-default mappings at your own risk. They may not always work. // Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace. // Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: mapping_channel, version: mapping_version mappings channel: mapping_channel, version: "${parchment_version}-${minecraft_version}"
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
// In most cases, it is not necessary to enable. // In most cases, it is not necessary to enable.
@ -41,6 +53,7 @@ minecraft {
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game. // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
// It is REQUIRED to be set to true for this template to function. // It is REQUIRED to be set to true for this template to function.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
copyIdeResources = true
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations. // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
// The folder name can be set on a run configuration using the "folderName" property. // The folder name can be set on a run configuration using the "folderName" property.
@ -74,6 +87,9 @@ minecraft {
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', mod_id
mods { mods {
"${mod_id}" { "${mod_id}" {
source sourceSets.main source sourceSets.main
@ -88,7 +104,7 @@ minecraft {
server { server {
property 'forge.enabledGameTestNamespaces', mod_id property 'forge.enabledGameTestNamespaces', mod_id
//args '--nogui' args '--nogui'
} }
// This run config launches GameTestServer and runs all registered gametests, then exits. // This run config launches GameTestServer and runs all registered gametests, then exits.
@ -112,18 +128,7 @@ minecraft {
sourceSets.main.resources { srcDir 'src/generated/resources' } sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories { repositories {
// Put repositories for dependencies here mavenCentral()
// ForgeGradle automatically adds the Forge maven and Maven Central for you
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
// flatDir {
// dir 'libs'
// }
maven {
name = "Aria's Creations Caches"
url = "https://maven.zontreck.com/repository/internal"
}
// Put repositories for dependencies here // Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you // ForgeGradle automatically adds the Forge maven and Maven Central for you
@ -139,8 +144,9 @@ repositories {
maven { maven {
name = "zontreck Maven" name = "zontreck Maven"
url = "https://maven.zontreck.com/repository/zontreck" url = "https://git.zontreck.com/api/packages/MinecraftMods/maven"
} }
} }
dependencies { dependencies {
@ -151,7 +157,8 @@ dependencies {
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository. // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
implementation fg.deobf("dev.zontreck:LibZontreckMod:${libzontreck}") provided "dev.zontreck:LibZontreck:${libzontreck}"
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}") // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
@ -168,9 +175,33 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/dependency_management.html // http://www.gradle.org/docs/current/userguide/dependency_management.html
} }
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version: forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description, libzontreck_id: libzontreck_id, libzontreck_range: libzontreck_range
]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}
// Example for how to get properties into the manifest for reading at runtime. // Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar).configure { tasks.named('jar', Jar).configure {
from {
configurations.provided.asFileTree.collect{zipTree(it)}
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest { manifest {
attributes([ attributes([
'Specification-Title' : mod_id, 'Specification-Title' : mod_id,
@ -192,20 +223,33 @@ tasks.named('jar', Jar).configure {
// dependsOn 'reobfJar' // dependsOn 'reobfJar'
// } // }
// Example configuration to allow publishing using the maven-publish plugin
def MAVEN_PASSWORD = "AriasCreationsMavenPassword"
def MAVEN_USER = "AriasCreationsMavenUser"
publishing { publishing {
publications { publications {
register('mavenJava', MavenPublication) { mavenJava(MavenPublication) {
artifact jar artifact jar
artifact sourcesJar
artifact javadocJar
} }
} }
repositories { repositories {
maven { maven {
url "file://${project.projectDir}/mcmodsrepo" url = "https://git.zontreck.com/api/packages/MinecraftMods/maven"
name = "ariascreations"
credentials {
username = project.findProperty(MAVEN_USER)
password = project.findProperty(MAVEN_PASSWORD)
}
} }
} }
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
} }

View file

@ -1,9 +1,11 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties. # Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process. # This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G -Dfile.encoding=utf-8
org.gradle.daemon=false org.gradle.daemon=false
libzontreck=1.10.020624.2226 libzontreck=1192.13.091224.1802
libzontreck_id=libzontreck
libzontreck_range=[1192.13,1192.14)
## Environment Properties ## Environment Properties
@ -12,9 +14,9 @@ minecraft_version=1.19.2
# The Minecraft version range can use any release version of Minecraft as bounds. # The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions. # as they do not follow standard versioning conventions.
minecraft_version_range=[1.19,1.20) minecraft_version_range=[1.19.2,1.20)
# The Forge version must agree with the Minecraft version to get a valid artifact # The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=43.3.0 forge_version=43.4.2
# The Forge version range can use any version of Forge as bounds or match the loader version range # The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[43,) forge_version_range=[43,)
# The loader version range can only use the major version of Forge/FML as bounds # The loader version range can only use the major version of Forge/FML as bounds
@ -36,8 +38,8 @@ loader_version_range=[43,)
mapping_channel=parchment mapping_channel=parchment
# The mapping version to query from the mapping channel. # The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel. # This must match the format required by the mapping channel.
mapping_version=2022.11.27-1.19.2 parchment_version=2022.11.27
# luckperms_api_version=5.4
## Mod Properties ## Mod Properties
@ -49,7 +51,7 @@ mod_name=Aria's Essentials
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3 mod_license=GPLv3
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1.2.020624.2241 mod_version=1192.3.091424.1448
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html

Binary file not shown.

View file

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -1,6 +1,14 @@
pluginManagement { pluginManagement {
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
maven { url = "https://maven.zontreck.com/repository/internal" } maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
maven { url = 'https://maven.parchmentmc.org' } // Add this line
} }
} }
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}

View file

@ -6,67 +6,66 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version # A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[43,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="GPLv3" license="${mod_license}"
# A URL to refer people to when problems occur with this mod # A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional #issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader # A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory [[mods]] #mandatory
# The modid of the mod # The modid of the mod
modId="ariasessentials" #mandatory modId="${mod_id}" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # The version number of the mod
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata version="${mod_version}" #mandatory
# see the associated build.gradle script for how to populate this completely automatically during a build
version="${file.jarVersion}" #mandatory
# A display name for the mod # A display name for the mod
displayName="Aria's Essentials" #mandatory displayName="${mod_name}" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ # A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional #updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI # A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional #displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
# A file name (in the root of the mod JAR) containing a logo for display # A file name (in the root of the mod JAR) containing a logo for display
logoFile="ariasessentials.png" #optional #logoFile="examplemod.png" #optional
# A text field displayed in the mod UI # A text field displayed in the mod UI
credits="Thanks for this example mod goes to Java" #optional #credits="" #optional
# A text field displayed in the mod UI # A text field displayed in the mod UI
authors="Love, Cheese and small house plants" #optional authors="${mod_authors}" #optional
# Display Test controls the display for your mod in the server connection screen # Display Test controls the display for your mod in the server connection screen
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. # MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. # IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. # IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. # NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. # IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) #displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
# The description text for the mod (multi line!) (#mandatory) # The description text for the mod (multi line!) (#mandatory)
description=''' description='''${mod_description}'''
Aria's Essentials mod. This provides a bunch of essential functions and commands
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.ariasessentials]] #optional [[dependencies.${mod_id}]] #optional
# the modid of the dependency # the modid of the dependency
modId="forge" #mandatory modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified # Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory mandatory=true #mandatory
# The version range of the dependency # The version range of the dependency
versionRange="[43,)" #mandatory versionRange="${forge_version_range}" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
# BEFORE - This mod is loaded BEFORE the dependency
# AFTER - This mod is loaded AFTER the dependency
ordering="NONE" ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER # Side this dependency is applied on - BOTH, CLIENT, or SERVER
side="BOTH" side="BOTH"
# Here's another dependency # Here's another dependency
[[dependencies.ariasessentials]] [[dependencies.${libzontreck_id}]]
modId="${libzontreck_id}"
mandatory=true
versionRange="${libzontreck_range}"
ordering="NONE"
side="BOTH"
[[dependencies.${mod_id}]]
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version # This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.19,1.20)" versionRange="${minecraft_version_range}"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.ariasessentials]]
modId="libzontreck"
mandatory=true
versionRange="[1.10,1.11)"
ordering="NONE"
side="BOTH"

View file

@ -1,8 +1,8 @@
{ {
"pack": { "pack": {
"description": "Aria's Essentials resources", "description": "${mod_id} resources",
"pack_format": 9, "pack_format": 9,
"forge:resource_pack_format": 9, "forge:resource_pack_format": 9,
"forge:data_pack_format": 10 "forge:data_pack_format": 10
} }
} }