diff --git a/build.gradle.kts b/build.gradle.kts
index 1755fe0e..60bbb60f 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -31,7 +31,6 @@ plugins {
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
id("dev.ithundxr.silk") version "0.11.+" // https://github.com/IThundxr/silk
id("dev.ithundxr.numismatics.gradle") apply false
- //id("dev.ithundxr.lotus.gradle") version "0.0.2" apply false
}
val isRelease = System.getenv("RELEASE_BUILD")?.toBoolean() ?: false
@@ -68,7 +67,7 @@ allprojects {
subprojects {
apply(plugin = "dev.architectury.loom")
apply(plugin = "dev.ithundxr.numismatics.gradle")
- //apply(plugin = "dev.ithundxr.lotus.gradle")
+ apply(plugin = "dev.ithundxr.lotus.gradle")
val capitalizedName = project.name.capitalized()
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 6208bf5a..4d26a8c5 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -25,6 +25,7 @@ plugins {
repositories {
gradlePluginPortal()
mavenCentral()
+ maven("https://maven.ithundxr.dev/releases")
}
gradlePlugin {
@@ -38,10 +39,10 @@ gradlePlugin {
dependencies {
implementation("org.ow2.asm:asm:${"asm_version"()}")
- //implementation("org.ow2.asm:asm-analysis:${"asm_version"()}")
- //implementation("org.ow2.asm:asm-commons:${"asm_version"()}")
implementation("org.ow2.asm:asm-tree:${"asm_version"()}")
implementation("org.ow2.asm:asm-util:${"asm_version"()}")
+
+ implementation("dev.ithundxr.lotus:lotus-gradle:${"lotus_gradle_version"()}")
}
operator fun String.invoke(): String {
diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties
index 60bd3a10..b9ed1051 100644
--- a/buildSrc/gradle.properties
+++ b/buildSrc/gradle.properties
@@ -16,4 +16,8 @@
# along with this program. If not, see .
#
+# Lotus
+# https://maven.ithundxr.dev/#/releases/dev/ithundxr/lotus/lotus-gradle
+lotus_gradle_version = 0.0.9
+
asm_version = 9.5
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/NumismaticsGradlePlugin.kt b/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/NumismaticsGradlePlugin.kt
index 14c1c620..09b23eeb 100644
--- a/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/NumismaticsGradlePlugin.kt
+++ b/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/NumismaticsGradlePlugin.kt
@@ -18,59 +18,13 @@
package dev.ithundxr.numismaticsgradle
-import dev.ithundxr.numismaticsgradle.asm.NumismaticsGradleASM
-import groovy.json.JsonOutput
-import groovy.json.JsonSlurper
+import dev.ithundxr.lotus.gradle.api.asm.LotusGradleASM
+import dev.ithundxr.numismaticsgradle.transformers.CCCapabilitiesTransformer
import org.gradle.api.Plugin
import org.gradle.api.Project
-import java.util.jar.JarEntry
-import java.util.jar.JarFile
-import java.util.jar.JarOutputStream
-import java.util.zip.Deflater
class NumismaticsGradlePlugin : Plugin {
override fun apply(project: Project) {
- project.tasks.named("remapJar").configure {
- doLast {
- val jar = outputs.files.singleFile
-
- var architecturyInjectableName = project.name
- if (project.rootProject != project)
- architecturyInjectableName = project.rootProject.name + "_" + architecturyInjectableName
-
- val contents = linkedMapOf()
- JarFile(jar).use {
- it.entries().asIterator().forEach { entry ->
- if (!entry.isDirectory) {
- contents[entry.name] = it.getInputStream(entry).readAllBytes()
- }
- }
- }
-
- jar.delete()
-
- JarOutputStream(jar.outputStream()).use { out ->
- out.setLevel(Deflater.BEST_COMPRESSION)
-
- contents.forEach { var (name, data) = it
- if (name.contains("architectury_inject_${architecturyInjectableName}_common"))
- return@forEach
-
- if (name.endsWith(".json") || name.endsWith(".mcmeta")) {
- data = (JsonOutput.toJson(JsonSlurper().parse(data)).toByteArray())
- } else if (name.endsWith(".class")) {
- data = NumismaticsGradleASM().transformClass(project, data)
- }
-
- out.putNextEntry(JarEntry(name))
- out.write(data)
- out.closeEntry()
- }
-
- out.finish()
- out.close()
- }
- }
- }
+ LotusGradleASM.addTransformer(CCCapabilitiesTransformer::class)
}
}
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/NumismaticsGradleASM.kt b/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/NumismaticsGradleASM.kt
deleted file mode 100644
index 3f058ffb..00000000
--- a/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/NumismaticsGradleASM.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Numismatics
- * Copyright (c) 2024 The Railways Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.ithundxr.numismaticsgradle.asm
-
-import dev.ithundxr.numismaticsgradle.asm.internal.SubprojectType
-import dev.ithundxr.numismaticsgradle.asm.transformers.CCCapabilitiesTransformer
-import org.gradle.api.Project
-import org.objectweb.asm.ClassReader
-import org.objectweb.asm.ClassWriter
-import org.objectweb.asm.tree.ClassNode
-import org.objectweb.asm.util.CheckClassAdapter
-
-class NumismaticsGradleASM {
- fun transformClass(project: Project, bytes: ByteArray): ByteArray {
- // Get project type
- val projectType = SubprojectType.getProjectType(project)
-
- val node = ClassNode()
- ClassReader(bytes).accept(node, 0)
-
- // Transformers
- CCCapabilitiesTransformer().transform(projectType, node)
-
- // Verify the bytecode is valid
- val byteArray = ClassWriter(0).also { node.accept(it) }.toByteArray()
- ClassReader(byteArray).accept(CheckClassAdapter(null), 0)
- return byteArray
- }
-}
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/internal/SubprojectType.kt b/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/internal/SubprojectType.kt
deleted file mode 100644
index baa204e8..00000000
--- a/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/internal/SubprojectType.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Numismatics
- * Copyright (c) 2024 The Railways Team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package dev.ithundxr.numismaticsgradle.asm.internal
-
-import org.gradle.api.Project
-
-enum class SubprojectType {
- COMMON, FABRIC, FORGE;
-
- companion object {
- fun getProjectType(project: Project): SubprojectType {
- return when (project.path) {
- ":common" -> COMMON
- ":fabric" -> FABRIC
- ":forge" -> FORGE
- else -> throw IllegalStateException("Invalid Project Type")
- }
- }
- }
-}
\ No newline at end of file
diff --git a/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/transformers/CCCapabilitiesTransformer.kt b/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/transformers/CCCapabilitiesTransformer.kt
similarity index 95%
rename from buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/transformers/CCCapabilitiesTransformer.kt
rename to buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/transformers/CCCapabilitiesTransformer.kt
index 89ac3720..1bc7cc96 100644
--- a/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/asm/transformers/CCCapabilitiesTransformer.kt
+++ b/buildSrc/src/main/kotlin/dev/ithundxr/numismaticsgradle/transformers/CCCapabilitiesTransformer.kt
@@ -16,16 +16,17 @@
* along with this program. If not, see .
*/
-package dev.ithundxr.numismaticsgradle.asm.transformers
+package dev.ithundxr.numismaticsgradle.transformers
-import dev.ithundxr.numismaticsgradle.asm.internal.SubprojectType
+import dev.ithundxr.lotus.gradle.api.asm.util.IClassTransformer
+import dev.ithundxr.lotus.gradle.api.asm.util.SubprojectType
import org.objectweb.asm.Label
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.ClassNode
-class CCCapabilitiesTransformer {
+class CCCapabilitiesTransformer : IClassTransformer {
@Suppress("LocalVariableName")
- fun transform(project: SubprojectType, node: ClassNode) {
+ override fun transform(project: SubprojectType, node: ClassNode) {
if (node.invisibleAnnotations != null && project == SubprojectType.FORGE) {
// Cache the field, so we don't CME the list during the remove
val annotationNodes = node.invisibleAnnotations.toList()
diff --git a/gradle.properties b/gradle.properties
index dab0faff..84344f49 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,3 +1,21 @@
+#
+# Numismatics
+# Copyright (c) 2024 The Railways Team
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+
org.gradle.jvmargs = -Xmx4G
# Mod Info