Skip to content

Commit

Permalink
Laby Gradle changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fesaa committed Oct 2, 2024
1 parent 414750b commit 01c7582
Show file tree
Hide file tree
Showing 9 changed files with 232 additions and 272 deletions.
11 changes: 4 additions & 7 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
version = "0.1.0"

plugins {
id("java-library")
}
import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType

dependencies {
labyProcessor()
labyApi("api")

// If you want to use external libraries, you can do that here.
Expand All @@ -16,8 +13,8 @@ dependencies {
// maven(mavenCentral(), "org.apache.httpcomponents:httpclient:4.5.13")
}

labyModProcessor {
referenceType = net.labymod.gradle.core.processor.ReferenceType.INTERFACE
labyModAnnotationProcessor {
referenceType = ReferenceType.INTERFACE
}

java {
Expand Down
140 changes: 21 additions & 119 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,145 +1,47 @@
import java.util.function.Supplier

plugins {
id("java-library")
id("net.labymod.gradle")
id("net.labymod.gradle.addon")
id("net.labymod.labygradle")
id("net.labymod.labygradle.addon")
id("signing")
id("maven-publish")
}

val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")
group = "art.ameliah.laby.addons"
version = "2.0.6"
version = providers.environmentVariable("VERSION").getOrElse("1.0.0")

java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))

labyMod {
defaultPackageName = "art.ameliah.laby.addons.cubepanion" //change this to your main package name (used by all modules)
addonInfo {
namespace = "cubepanion"
displayName = "Cubepanion"
author = "Fesa"
description = "A CubeCraft focused LabyMod addon that provides a ton of useful features!\nNot affiliated with Ziax/CubeCraft in any way."
minecraftVersion = "1.20<*"
version = System.getenv().getOrDefault("VERSION", "0.0.1")
}
defaultPackageName = "art.ameliah.laby.addons.cubepanion"

minecraft {
registerVersions(
"1.20.1",
"1.20.2",
"1.20.4",
"1.20.5",
"1.20.6",
"1.21",
"1.21.1",
) { version, provider ->
configureRun(provider, version)

provider.accessWidener = Supplier {
val sourceSetName = version.replace(".", "_").replace("-", "_")
file("./game-runner/src/v$sourceSetName/resources/cubepanion-$version.accesswidener")
registerVersion(versions.toTypedArray()) {
runs {
getByName("client")
}
}

subprojects.forEach {
if (it.name != "game-runner") {
filter(it.name)
}
val file = file("./game-runner/src/${this.sourceSetName}/resources/cubepanion-${versionId}.accesswidener")
accessWidener.set(file)
}
}

addonDev {
productionRelease()
addonInfo {
namespace = "cubepanion"
displayName = "Cubepanion"
author = "Amelia"
description = "A CubeCraft focused LabyMod addon that provides a ton of useful features!\nNot affiliated with Ziax/CubeCraft in any way."
minecraftVersion = "1.20<*"
version = rootProject.version.toString()
}
}

subprojects {
plugins.apply("java-library")
plugins.apply("net.labymod.gradle")
plugins.apply("net.labymod.gradle.addon")

repositories {
maven("https://libraries.minecraft.net/")
maven("https://repo.spongepowered.org/repository/maven-public/")
}

val shade = configurations.create("shade")
val api by configurations
api.extendsFrom(shade)
}

fun configureRun(provider: net.labymod.gradle.core.minecraft.provider.VersionProvider, gameVersion: String) {
provider.runConfiguration {
mainClass = "net.minecraft.launchwrapper.Launch"
jvmArgs("-Dnet.labymod.running-version=${gameVersion}")
jvmArgs("-Dmixin.debug=true")
jvmArgs("-Dnet.labymod.debugging.all=true")
jvmArgs("-Dmixin.env.disableRefMap=true")

if (org.gradle.internal.os.OperatingSystem.current() == org.gradle.internal.os.OperatingSystem.MAC_OS) {
jvmArgs("-XstartOnFirstThread")
}

args("--tweakClass", "net.labymod.core.loader.vanilla.launchwrapper.Java17LabyModLaunchWrapperTweaker")
args("--labymod-dev-environment", "true")
args("--addon-dev-environment", "true")
}

provider.javaVersion = JavaVersion.VERSION_21

provider.mixin {
val mixinMinVersion = when (gameVersion) {
"1.8.9", "1.12.2", "1.16.5" -> {
"0.6.6"
}
plugins.apply("net.labymod.labygradle")
plugins.apply("net.labymod.labygradle.addon")

else -> {
"0.8.2"
}
}

minVersion = mixinMinVersion
}
group = rootProject.group
version = rootProject.version
}

configurations {
create("conf")
}
val rFile = layout.buildDirectory.file("libs//cubepanion-release.jar")
val rArtifact = artifacts.add("conf", rFile.get().asFile) {
type = "jar"
builtBy("build")
}



publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "cubepanion"
artifact(rArtifact)

pom {
name.set("cubepanion")
description.set("CubeCraft Laby Addon")
url.set("https://github.com/Fesaa/Cubepanion")

licenses {
license {
name.set("MIT License")
url.set("https://mit-license.org/")
}
}

developers {
developer {
id.set("amelia")
name.set("Amelia")
}
}
}
}
}
}

19 changes: 4 additions & 15 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
version = "0.1.0"

plugins {
id("java-library")
}
import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType

dependencies {
labyProcessor()
api(project(":api"))

// If you want to use external libraries, you can do that here.
// The dependencies that are specified here are loaded into your project but will also
// automatically be downloaded by labymod, but only if the repository is public.
// If it is private, you have to add and compile the dependency manually.
// You have to specify the repository, there are getters for maven central and sonatype, every
// other repository has to be specified with their url. Example:
// maven(mavenCentral(), "org.apache.httpcomponents:httpclient:4.5.13")

compileOnly("io.netty:netty-all:4.0.23.Final")
}

labyModProcessor {
referenceType = net.labymod.gradle.core.processor.ReferenceType.DEFAULT
labyModAnnotationProcessor {
referenceType = ReferenceType.DEFAULT
}

java {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx4096m
org.gradle.jvmargs=-Xmx4096m
net.labymod.minecraft-versions=1.20.1;1.20.2;1.20.4;1.20.5;1.20.6;1.21;1.21.1
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-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 01c7582

Please sign in to comment.