|
| 1 | +@file:Suppress("UnstableApiUsage") |
| 2 | +import com.smushytaco.lwjgl_gradle.Preset |
| 3 | +plugins { |
| 4 | + alias(libs.plugins.loom) |
| 5 | + alias(libs.plugins.lwjgl) |
| 6 | + java |
| 7 | + `maven-publish` |
| 8 | +} |
| 9 | +val modVersion = providers.gradleProperty("mod_version") |
| 10 | +val modGroup = providers.gradleProperty("mod_group") |
| 11 | +val modName = providers.gradleProperty("mod_name") |
| 12 | + |
| 13 | +val javaVersion = libs.versions.java.map { it.toInt() } |
| 14 | + |
| 15 | +base.archivesName = modName |
| 16 | +group = modGroup.get() |
| 17 | +version = modVersion.get() |
| 18 | +loom { |
| 19 | + noIntermediateMappings() |
| 20 | + customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/v${libs.versions.bta.get()}/manifest.json") |
| 21 | +} |
| 22 | +repositories { |
| 23 | + mavenCentral() |
| 24 | + maven("https://jitpack.io") |
| 25 | + maven("https://maven.fabricmc.net/") { name = "Fabric" } |
| 26 | + maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" } |
| 27 | + maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" } |
| 28 | + ivy("https://github.com/Better-than-Adventure") { |
| 29 | + patternLayout { artifact("[organisation]/releases/download/v[revision]/[module].jar") } |
| 30 | + metadataSources { artifact() } |
| 31 | + } |
| 32 | + ivy("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/") { |
| 33 | + patternLayout { artifact("/v[revision]/client.jar") } |
| 34 | + metadataSources { artifact() } |
| 35 | + } |
| 36 | + ivy("https://downloads.betterthanadventure.net/bta-server/${libs.versions.btaChannel.get()}/") { |
| 37 | + patternLayout { artifact("/v[revision]/server.jar") } |
| 38 | + metadataSources { artifact() } |
| 39 | + } |
| 40 | + ivy("https://piston-data.mojang.com") { |
| 41 | + patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") } |
| 42 | + metadataSources { artifact() } |
| 43 | + } |
| 44 | +} |
| 45 | +lwjgl { |
| 46 | + version = libs.versions.lwjgl |
| 47 | + implementation(Preset.MINIMAL_OPENGL) |
| 48 | +} |
| 49 | +dependencies { |
| 50 | + minecraft("::${libs.versions.bta.get()}") |
| 51 | + mappings(loom.layered {}) |
| 52 | + |
| 53 | + // https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar |
| 54 | + modRuntimeOnly("objects:client:43db9b498cb67058d2e12d394e6507722e71bb45") |
| 55 | + modImplementation(libs.loader) |
| 56 | + modImplementation(libs.legacyLwjgl) |
| 57 | + |
| 58 | + implementation(libs.slf4jApi) |
| 59 | + implementation(libs.guava) |
| 60 | + implementation(libs.log4j.slf4j2.impl) |
| 61 | + implementation(libs.log4j.core) |
| 62 | + implementation(libs.log4j.api) |
| 63 | + implementation(libs.log4j.api12) |
| 64 | + implementation(libs.gson) |
| 65 | + |
| 66 | + implementation(libs.commonsLang3) |
| 67 | + include(libs.commonsLang3) |
| 68 | +} |
| 69 | +java { |
| 70 | + toolchain { |
| 71 | + languageVersion = javaVersion.map { JavaLanguageVersion.of(it) } |
| 72 | + vendor = JvmVendorSpec.ADOPTIUM |
| 73 | + } |
| 74 | + sourceCompatibility = JavaVersion.toVersion(javaVersion.get()) |
| 75 | + targetCompatibility = JavaVersion.toVersion(javaVersion.get()) |
| 76 | + withSourcesJar() |
| 77 | +} |
| 78 | +val licenseFile = run { |
| 79 | + val rootLicense = layout.projectDirectory.file("LICENSE") |
| 80 | + val parentLicense = layout.projectDirectory.file("../LICENSE") |
| 81 | + when { |
| 82 | + rootLicense.asFile.exists() -> { |
| 83 | + logger.lifecycle("Using LICENSE from project root: {}", rootLicense.asFile) |
| 84 | + rootLicense |
| 85 | + } |
| 86 | + parentLicense.asFile.exists() -> { |
| 87 | + logger.lifecycle("Using LICENSE from parent directory: {}", parentLicense.asFile) |
| 88 | + parentLicense |
| 89 | + } |
| 90 | + else -> { |
| 91 | + logger.warn("No LICENSE file found in project or parent directory.") |
| 92 | + null |
| 93 | + } |
| 94 | + } |
| 95 | +} |
| 96 | +tasks { |
| 97 | + withType<JavaCompile>().configureEach { |
| 98 | + options.encoding = "UTF-8" |
| 99 | + sourceCompatibility = javaVersion.get().toString() |
| 100 | + targetCompatibility = javaVersion.get().toString() |
| 101 | + if (javaVersion.get() > 8) options.release = javaVersion |
| 102 | + } |
| 103 | + named<UpdateDaemonJvm>("updateDaemonJvm") { |
| 104 | + languageVersion = libs.versions.gradleJava.map { JavaLanguageVersion.of(it.toInt()) } |
| 105 | + vendor = JvmVendorSpec.ADOPTIUM |
| 106 | + } |
| 107 | + withType<JavaExec>().configureEach { defaultCharacterEncoding = "UTF-8" } |
| 108 | + withType<Javadoc>().configureEach { options.encoding = "UTF-8" } |
| 109 | + withType<Test>().configureEach { defaultCharacterEncoding = "UTF-8" } |
| 110 | + withType<Jar>().configureEach { |
| 111 | + licenseFile?.let { |
| 112 | + from(it) { |
| 113 | + rename { original -> "${original}_${archiveBaseName.get()}" } |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + processResources { |
| 118 | + val resourceMap = mapOf( |
| 119 | + "version" to modVersion.get(), |
| 120 | + "fabricloader" to libs.versions.loader.get(), |
| 121 | + "java" to libs.versions.java.get() |
| 122 | + ) |
| 123 | + inputs.properties(resourceMap) |
| 124 | + filesMatching("fabric.mod.json") { expand(resourceMap) } |
| 125 | + filesMatching("**/*.mixins.json") { expand(resourceMap.filterKeys { it == "java" }) } |
| 126 | + } |
| 127 | +} |
| 128 | +// Removes LWJGL2 dependencies |
| 129 | +configurations.configureEach { exclude(group = "org.lwjgl.lwjgl") } |
| 130 | + |
| 131 | +publishing { |
| 132 | + repositories { |
| 133 | + maven("https://maven.thesignalumproject.net/releases") { |
| 134 | + name = "signalumMaven" |
| 135 | + credentials(PasswordCredentials::class) |
| 136 | + authentication { |
| 137 | + create<BasicAuthentication>("basic") |
| 138 | + } |
| 139 | + } |
| 140 | + } |
| 141 | + publications { |
| 142 | + create<MavenPublication>("maven") { |
| 143 | + groupId = modGroup.get() |
| 144 | + artifactId = modName.get() |
| 145 | + version = modVersion.get() |
| 146 | + from(components["java"]) |
| 147 | + } |
| 148 | + } |
| 149 | +} |
0 commit comments