Skip to content

Commit

Permalink
Modernize CI and gradle.properties usage
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Dec 12, 2024
1 parent 8f256f6 commit 70efbd9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 48 deletions.
60 changes: 43 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ apply plugin: 'maven-publish'
String build_number = "DEV" // this will be referenced as simply build_number from now on.
if (System.getenv().BUILD_NUMBER)
build_number = System.getenv().BUILD_NUMBER
if (System.getenv().TRAVIS_BUILD_NUMBER)
build_number = System.getenv().TRAVIS_BUILD_NUMBER
if (System.getenv().GITHUB_RUN_ID)
build_number = System.getenv().GITHUB_RUN_NUMBER
if (System.getenv().RELEASE || System.getenv().TRAVIS_TAG)
if (System.getenv().RELEASE)
build_number = "RELEASE"
logger.lifecycle "BUILDING VERSION: " + build_number

// Set mod details
version = project.mod_version
group = "org.cyclops.integratedtunnelscompat"
archivesBaseName = "IntegratedTunnelsCompat-${project.minecraft_version}-neoforge"
// Include build number in version
if (build_number.equals("RELEASE"))
version = "${project.mod_version}"
else
version = "${project.mod_version}-${build_number}"

base {
archivesName = archivesBaseName
archivesName = "${mod_id}-${minecraft_version}-neoforge"
}

// Set Java details
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
java {
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
}
compileJava.options.compilerArgs << "-Xmaxerrs" << "9999"
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

// Load secrets
def getSecrets() {
Expand All @@ -39,7 +39,10 @@ def getSecrets() {
}
return props
}
Properties secrets = getSecrets();
//ext {
Properties secrets = getSecrets();
secrets.build_number = build_number;
//}

sourceSets {
main
Expand Down Expand Up @@ -143,11 +146,6 @@ runs {
}
}

if (build_number.equals("RELEASE"))
version = "${project.mod_version}"
else
version = "${project.mod_version}-${build_number}"

jar {
manifest {
attributes([
Expand Down Expand Up @@ -196,6 +194,34 @@ artifacts {
archives javadocJar
}

// Replace properties in files
processResources {
def expandProps = [
'mod_version' : mod_version,
'group' : project.group, //Else we target the task's group.
'minecraft_version' : minecraft_version,
'mod_name' : mod_name,
'mod_author' : mod_author,
'mod_id' : mod_id,
'license' : license,
'issue_tracker_url' : issue_tracker_url,
'display_url' : display_url,
'description' : project.description,
'neoforge_version' : neoforge_version,
'neoforge_loader_version_range' : neoforge_loader_version_range,
'java_version' : java_version,
'cyclopscore_version' : cyclopscore_version,
'cyclopscore_version_semver' : cyclopscore_version.replaceAll("-.*\$", ""),
'integratedtunnels_version' : integratedtunnels_version,
'integratedtunnels_version_semver' : integratedtunnels_version.replaceAll("-.*\$", "")
]

filesMatching(['pack.mcmeta', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', 'mixins.*.json']) {
expand expandProps
}
inputs.properties(expandProps)
}

publishing {
repositories {
if (project.hasProperty("filesmaven_url")) {
Expand Down
32 changes: 20 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
mod_id=integratedtunnels-compat
# Project
mod_version=1.0.0
group=org.cyclops.integratedtunnelscompat
java_version=21

# Common
minecraft_version=1.21.1
neoforge_version=21.1.2
mod_name=IntegratedTunnels-Compat
mod_author=rubensworks (aka kroeser)
mod_id=integratedtunnelscompat
license=MIT
github_url=https://github.com/CyclopsMC/IntegratedTunnels-Compat
issue_tracker_url=https://github.com/CyclopsMC/IntegratedTunnels-Compat/issues
display_url=https://www.curseforge.com/minecraft/mc-mods/integrated-tunnels
description=Integrated Tunnels compatibility with other mods.

parchment_version=2024.07.07
parchment_minecraft_version=1.21

# NeoForge
neoforge_version=21.1.2
neoforge_loader_version_range=[4,)

# Dependencies
cyclopscore_version=1.25.1-627
integrateddynamics_version=1.23.2-832
integratedtunnels_version=1.8.27-310
release_type=release

commoncapabilities_version=2.9.3-147

# Workaround for Spotless bug
# https://github.com/diffplug/spotless/issues/834
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
36 changes: 17 additions & 19 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
modLoader="javafml"
loaderVersion="[2,)"
issueTrackerURL="https://github.com/CyclopsMC/IntegratedTunnels-Compat/issues"
displayURL="https://www.curseforge.com/minecraft/mc-mods/integrated-tunnels"
license="MIT"
loaderVersion="${neoforge_loader_version_range}"
issueTrackerURL="${issue_tracker_url}"
displayURL="${display_url}"
license="${license}"
logoFile="logo.png"
authors="rubensworks (aka kroeser)"
authors="${mod_author}"
[[mods]]
modId="integratedtunnelscompat"
version="${file.jarVersion}"
displayName="IntegratedTunnels-Compat"
description='''
Integrated Tunnels compatibility with other mods.
'''
[[dependencies.integratedtunnelscompat]]
modId="${mod_id}"
version="${mod_version}"
displayName="${mod_name}"
description="${description}"
[[dependencies.${mod_id}]]
modId="cyclopscore"
type="required"
versionRange="[1.25.1,)"
versionRange="[${cyclopscore_version_semver},)"
ordering="NONE"
side="BOTH"
[[dependencies.integratedtunnelscompat]]
[[dependencies.${mod_id}]]
modId="integratedtunnels"
type="required"
versionRange="[1.8.11,)"
versionRange="[${integratedtunnels_version_semver},)"
ordering="NONE"
side="BOTH"
[[dependencies.integratedtunnelscompat]]
[[dependencies.${mod_id}]]
modId="neoforge"
type="required"
versionRange="[21.1.2,)"
versionRange="[${neoforge_version},)"
ordering="NONE"
side="BOTH"
[[dependencies.integratedtunnelscompat]]
[[dependencies.${mod_id}]]
modId="minecraft"
type="required"
versionRange="[1.21.1,]"
versionRange="[${minecraft_version},]"
ordering="NONE"
side="BOTH"

0 comments on commit 70efbd9

Please sign in to comment.