Skip to content

Commit

Permalink
Move to almostgradle
Browse files Browse the repository at this point in the history
  • Loading branch information
LLytho committed Sep 13, 2024
1 parent ff920e3 commit 6a24b36
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 120 deletions.
120 changes: 6 additions & 114 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,129 +1,21 @@
@file:Suppress("UnstableApiUsage")

val license: String by project
val neoforgeVersion: String by project
val minecraftVersion: String by project
val modPackage: String by project
val modVersion: String by project
val modId: String by project
val modName: String by project
val modDescription: String by project
val modAuthor: String by project
val githubRepo: String by project
val githubUser: String by project
val kubejsVersion: String by project

plugins {
java
`maven-publish`
id("net.neoforged.moddev") version "1.0.10"
id("com.github.gmazzo.buildconfig") version "4.0.4"
id("net.neoforged.moddev") version "2.0.19-beta"
id("com.almostreliable.almostgradle") version "1.0.+"
}

repositories {
mavenLocal()
maven("https://maven.saps.dev/minecraft")
maven("https://www.cursemaven.com")
}

base {
archivesName.set("$modId-neoforge")
version = "$minecraftVersion-$modVersion"
}

neoForge {
version = neoforgeVersion

addModdingDependenciesTo(sourceSets.test.get())

val mainMod = mods.create(modId) {
sourceSet(sourceSets.main.get())
}

mods.create("testmod") {
sourceSet(sourceSets.test.get())
}

runs {
val exampleScripts = project.rootDir.resolve("example_scripts").toString()
create("gametest") {
server()
sourceSet.set(sourceSets.test.get())
systemProperty("neoforge.gameTestServer", "true")
systemProperty("neoforge.enabledGameTestNamespaces", modId)
systemProperty("$modId.example_scripts", exampleScripts)
}
create("testmod") {
client()
sourceSet.set(sourceSets.test.get())
systemProperty("neoforge.gameTestServer", "true")
systemProperty("neoforge.enabledGameTestNamespaces", modId)
systemProperty("$modId.example_scripts", exampleScripts)
}
create("client") {
client()
mods.set(setOf(mainMod))
}
create("server") {
server()
mods.set(setOf(mainMod))
}
configureEach {
jvmArgument("-XX:+IgnoreUnrecognizedVMOptions")
jvmArgument("-XX:+AllowEnhancedClassRedefinition")
if (type.get() == "client") {
programArguments.addAll("--width", "1920", "--height", "1080")
}
}
}
almostgradle.setup {
testMod = true
}

dependencies {
val kubejsVersion: String by project
implementation("dev.latvian.mods:kubejs-neoforge:${kubejsVersion}")
testImplementation("dev.latvian.mods:kubejs-neoforge:${kubejsVersion}")

implementation("com.google.code.findbugs:jsr305:3.0.2")
}

tasks {
/**
* Resource processing for defined targets. This will replace `${key}` with the specified values from the map below.
*/
processResources {
val resourceTargets = listOf("META-INF/neoforge.mods.toml", "pack.mcmeta")

val replaceProperties = mapOf(
"version" to project.version as String,
"license" to license,
"modId" to modId,
"modName" to modName,
"minecraftVersion" to minecraftVersion,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"neoforgeVersion" to neoforgeVersion,
"githubUser" to githubUser,
"githubRepo" to githubRepo,
"kubejsVersion" to kubejsVersion
)

println("[Process Resources] Replacing properties in resources: ")
replaceProperties.forEach { (key, value) -> println("\t -> $key = $value") }

inputs.properties(replaceProperties)
filesMatching(resourceTargets) {
expand(replaceProperties)
}
}
}

extensions.configure<JavaPluginExtension> {
withSourcesJar()
}

buildConfig {
buildConfigField("String", "MOD_ID", "\"$modId\"")
buildConfigField("String", "MOD_NAME", "\"$modName\"")
buildConfigField("String", "MOD_VERSION", "\"$version\"")
packageName(modPackage)
useJavaOutput()
localRuntime(almostgradle.recipeViewers.emi.dependency)
}
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
group = com.almostreliable.mods
group = com.almostreliable
license = GNU Lesser General Public License v3.0
loom.platform = neoforge

# Mod options
modPackage = com.almostreliable.morejs
modId = morejs
modName = MoreJS
modVersion = 0.13.0
Expand All @@ -15,9 +13,12 @@ minecraftVersion = 1.21
neoforgeVersion = 21.0.167
kubejsVersion = 2100.7.0-build.119

# Github
githubUser = AlmostReliable
githubRepo = morejs
# AlmostGradle
almostgradle.launchArgs.resizeClient = true
almostgradle.launchArgs.autoWorldJoin = true

almostgradle.recipeViewers.emi.version = 1.1.12
almostgradle.recipeViewers.emi.minecraftVersion = 1.21

# Parchment
neoForge.parchment.minecraftVersion = 1.21
Expand Down

0 comments on commit 6a24b36

Please sign in to comment.