aboutsummaryrefslogtreecommitdiff
path: root/build.gradle.kts
diff options
context:
space:
mode:
authorMoulberry <jjenour@student.unimelb.edu.au>2022-10-15 16:14:46 +0200
committerGitHub <noreply@github.com>2022-10-15 16:14:46 +0200
commit9dff9de9be425a07691951f7f7e6d43ca2c967bf (patch)
tree525c4086b4b8cb9ee2a329dee7a0915ceaaa788a /build.gradle.kts
parent7c6d37b2eb758a13b342b906f0aef88b940bc52a (diff)
parentdf02addf3404f07f245d6e6da8ce3ee8d72bd235 (diff)
downloadNotEnoughUpdates-9dff9de9be425a07691951f7f7e6d43ca2c967bf.tar.gz
NotEnoughUpdates-9dff9de9be425a07691951f7f7e6d43ca2c967bf.tar.bz2
NotEnoughUpdates-9dff9de9be425a07691951f7f7e6d43ca2c967bf.zip
Merge pull request #268 from NotEnoughUpdates/masterv2.1.0
2.1 Continued
Diffstat (limited to 'build.gradle.kts')
-rw-r--r--build.gradle.kts255
1 files changed, 143 insertions, 112 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index e824a9a0..deb740f5 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,149 +1,180 @@
-import java.io.ByteArrayOutputStream
-import net.minecraftforge.gradle.user.ReobfMappingType
+/*
+ * Copyright (C) 2022 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+
+import neubs.NEUBuildFlags
+import neubs.applyPublishingInformation
+import neubs.setVersionFromEnvironment
+
plugins {
- java
- id("net.minecraftforge.gradle.forge") version "6f5327738df"
- id("com.github.johnrengelman.shadow") version "6.1.0"
- id("org.spongepowered.mixin") version "d75e32e"
+ idea
+ java
+ id("gg.essential.loom") version "0.10.0.+"
+ id("dev.architectury.architectury-pack200") version "0.1.3"
+ id("com.github.johnrengelman.shadow") version "7.1.2"
+ id("io.github.juuxel.loom-quiltflower") version "1.7.3"
+ `maven-publish`
}
-group = "io.github.moulberry"
-val baseVersion = "2.1"
-
-
-var buildVersion = properties["BUILD_VERSION"]
-if (buildVersion == null) {
- val stdout = ByteArrayOutputStream()
- val execResult = exec {
- commandLine("git", "describe", "--always", "--first-parent", "--abbrev=7")
- standardOutput = stdout
- }
- if (execResult.exitValue == 0)
- buildVersion = String(stdout.toByteArray()).trim()
-}
-version = baseVersion + (buildVersion?.let { "+$it" } ?: "")
+apply<NEUBuildFlags>()
+// Build metadata
-// Toolchains:
+group = "io.github.moulberry"
-java {
- // Forge Gradle currently prevents using the toolchain: toolchain.languageVersion.set(JavaLanguageVersion.of(8))
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
+setVersionFromEnvironment("2.1")
+
+// Minecraft configuration:
+loom {
+ launchConfigs {
+ "client" {
+ property("mixin.debug", "true")
+ property("asmhelper.verbose", "true")
+ arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
+ arg("--mixin", "mixins.notenoughupdates.json")
+ }
+ }
+ runConfigs {
+ "server" {
+ isIdeConfigGenerated = false
+ }
+ }
+ forge {
+ pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
+ mixinConfig("mixins.notenoughupdates.json")
+ }
+ mixin {
+ defaultRefmapName.set("mixins.notenoughupdates.refmap.json")
+ }
}
-minecraft {
- version = "1.8.9-11.15.1.2318-1.8.9"
- runDir = "run"
- mappings = "stable_22"
- clientJvmArgs.addAll(
- listOf(
- "-Dmixin.debug=true",
- "-Dasmhelper.verbose=true"
- )
- )
- clientRunArgs.addAll(
- listOf(
- "--tweakClass org.spongepowered.asm.launch.MixinTweaker",
- "--mixin mixins.notenoughupdates.json"
- )
- )
+
+// Dependencies:
+repositories {
+ mavenCentral()
+ mavenLocal()
+ maven("https://repo.spongepowered.org/maven/")
+ maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
+ maven("https://jitpack.io")
}
-mixin {
- add(sourceSets.main.get(), "mixins.notenoughupdates.refmap.json")
+val shadowImplementation by configurations.creating {
+ configurations.implementation.get().extendsFrom(this)
}
-// Dependencies:
+val shadowApi by configurations.creating {
+ configurations.implementation.get().extendsFrom(this)
+}
-repositories {
- mavenCentral()
- flatDir { dirs("deps/") }
- maven("https://repo.spongepowered.org/maven/")
+val devEnv by configurations.creating {
+ configurations.runtimeClasspath.get().extendsFrom(this)
+ isCanBeResolved = false
+ isCanBeConsumed = false
+ isVisible = false
}
dependencies {
- implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT")
- annotationProcessor("org.spongepowered:mixin:0.7.11-SNAPSHOT")
- implementation("com.fasterxml.jackson.core:jackson-core:2.13.1")
- implementation("info.bliki.wiki:bliki-core:3.1.0")
+ minecraft("com.mojang:minecraft:1.8.9")
+ mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
+ forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
+
+ shadowImplementation("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
+ isTransitive = false // Dependencies of mixin are already bundled by minecraft
+ }
+ annotationProcessor("org.spongepowered:mixin:0.8.4-SNAPSHOT")
+ shadowApi("info.bliki.wiki:bliki-core:3.1.0")
+ testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
+ testAnnotationProcessor("org.spongepowered:mixin:0.8.4-SNAPSHOT")
+ // modImplementation("io.github.notenoughupdates:MoulConfig:0.0.1")
+
+ devEnv("me.djtheredstoner:DevAuth-forge-legacy:1.1.0")
}
+
+java {
+ withSourcesJar()
+ toolchain.languageVersion.set(JavaLanguageVersion.of(8))
+}
+
// Tasks:
tasks.withType(JavaCompile::class) {
- options.encoding = "UTF-8"
+ options.encoding = "UTF-8"
}
-tasks.withType(Jar::class) {
- archiveBaseName.set("NotEnoughUpdates")
- manifest.attributes.run {
- this["Main-Class"] = "NotSkyblockAddonsInstallerFrame"
- this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
- this["MixinConfigs"] = "mixins.notenoughupdates.json"
- this["FMLCorePluginContainsFMLMod"] = "true"
- this["ForceLoadAsMod"] = "true"
- this["FMLAT"] = "notenoughupdates_at.cfg"
- }
+tasks.named<Test>("test") {
+ useJUnitPlatform()
}
-tasks.shadowJar {
- archiveClassifier.set("dep")
- exclude(
- "module-info.class",
- "LICENSE.txt"
- )
- dependencies {
- include(dependency("org.spongepowered:mixin:0.7.11-SNAPSHOT"))
-
- include(dependency("commons-io:commons-io"))
- include(dependency("org.apache.commons:commons-lang3"))
- include(dependency("com.fasterxml.jackson.core:jackson-databind:2.10.2"))
- include(dependency("com.fasterxml.jackson.core:jackson-annotations:2.10.2"))
- include(dependency("com.fasterxml.jackson.core:jackson-core:2.10.2"))
-
- include(dependency("info.bliki.wiki:bliki-core:3.1.0"))
- include(dependency("org.slf4j:slf4j-api:1.7.18"))
- include(dependency("org.luaj:luaj-jse:3.0.1"))
- }
- fun relocate(name: String) = relocate(name, "io.github.moulberry.notenoughupdates.deps.$name")
- relocate("com.fasterxml.jackson")
- relocate("org.eclipse")
- relocate("org.slf4j")
+tasks.withType(Jar::class) {
+ archiveBaseName.set("NotEnoughUpdates")
+ manifest.attributes.run {
+ this["Main-Class"] = "NotSkyblockAddonsInstallerFrame"
+ this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
+ this["MixinConfigs"] = "mixins.notenoughupdates.json"
+ this["FMLCorePluginContainsFMLMod"] = "true"
+ this["ForceLoadAsMod"] = "true"
+ this["Manifest-Version"] = "1.0"
+ }
}
-tasks.build.get().dependsOn(tasks.shadowJar)
+val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") {
+ archiveClassifier.set("dep")
+ from(tasks.shadowJar)
+ input.set(tasks.shadowJar.get().archiveFile)
+ doLast {
+ println("Jar name: ${archiveFile.get().asFile}")
+ }
+}
-reobf {
- create("shadowJar") {
- mappingType = ReobfMappingType.SEARGE
- }
+tasks.shadowJar {
+ archiveClassifier.set("dep-dev")
+ configurations = listOf(shadowImplementation, shadowApi)
+ exclude("**/module-info.class", "LICENSE.txt")
+ dependencies {
+ exclude {
+ it.moduleGroup.startsWith("org.apache.") || it.moduleName in
+ listOf("logback-classic", "commons-logging", "commons-codec", "logback-core")
+ }
+ }
+ fun relocate(name: String) = relocate(name, "io.github.moulberry.notenoughupdates.deps.$name")
}
+tasks.assemble.get().dependsOn(remapJar)
+
tasks.processResources {
- from(sourceSets.main.get().resources.srcDirs)
- filesMatching("mcmod.info") {
- expand(
- "version" to project.version,
- "mcversion" to minecraft.version
- )
- }
- rename("(.+_at.cfg)".toPattern(), "META-INF/$1")
+ from(tasks["generateBuildFlags"])
+ filesMatching(listOf("mcmod.info", "fabric.mod.json", "META-INF/mods.toml")) {
+ expand(
+ "version" to project.version, "mcversion" to "1.8.9"
+ )
+ }
}
-val moveResources by tasks.creating {
- doLast {
- ant.withGroovyBuilder {
- "move"(
- "file" to "$buildDir/resources/main",
- "todir" to "$buildDir/classes/java"
- )
- }
- }
- dependsOn(tasks.processResources)
+sourceSets.main {
+ output.setResourcesDir(file("$buildDir/classes/java/main"))
}
-tasks.classes { dependsOn(moveResources) }
-
+applyPublishingInformation(
+ "deobf" to tasks.jar,
+ "all" to tasks.remapJar,
+ "sources" to tasks["sourcesJar"],
+)