Skip to content
2 changes: 1 addition & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repositories {
}

dependencies {
api("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
api("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:8.3.9")

implementation("org.ow2.asm:asm-commons:9.3")
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package essential

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.ArchiveOperations
import org.gradle.kotlin.dsl.support.serviceOf

fun ShadowJar.configureModLauncherContainerJar(configuration: Configuration) {
dependsOn(configuration)
from({ project.zipTree(configuration.singleFile) })
val archiveOps = project.serviceOf<ArchiveOperations>()
from({ archiveOps.zipTree(configuration.singleFile) })
preserveJars()

// We cannot relocate the whole package cause the stage1.jar must remain in the same place
Expand Down
4 changes: 2 additions & 2 deletions build-logic/src/main/kotlin/essential/shadowWithInnerJars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext
import org.gradle.api.file.FileTreeElement
import shadow.org.apache.tools.zip.ZipEntry
import shadow.org.apache.tools.zip.ZipOutputStream
import org.apache.tools.zip.ZipEntry
import org.apache.tools.zip.ZipOutputStream

/**
* Shadow by default recursively explodes all jar files.
Expand Down
13 changes: 5 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ subprojects {
apply plugin: "java"

group = "gg.essential"
archivesBaseName = "essential-loader" + path.replace(':', '-')
base {
archivesName = "essential-loader" + path.replace(':', '-')
}

def javaVersions = [
"compatibility": 16,
Expand All @@ -19,18 +21,13 @@ subprojects {
"modlauncher11": 21,
]
java.toolchain.languageVersion.set(JavaLanguageVersion.of(javaVersions.getOrDefault(project.name, 8)))

repositories {
mavenCentral()
maven { url "https://libraries.minecraft.net/" }
}
}

allprojects {
tasks.withType(AbstractArchiveTask.class).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
dirMode = 0755
fileMode = 0644
dirPermissions { unix("755") }
filePermissions { unix("644") }
}
}
2 changes: 1 addition & 1 deletion container/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
}

val jar by tasks.registering(Jar::class) {
destinationDirectory.set(project.buildDir.resolve("libs"))
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveBaseName.set("container-${project.name}")

dependsOn(stage0)
Expand Down
2 changes: 1 addition & 1 deletion container/launchwrapper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
}

val jar by tasks.registering(Jar::class) {
destinationDirectory.set(project.buildDir.resolve("libs"))
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveBaseName.set("container-${project.name}")

dependsOn(stage0)
Expand Down
2 changes: 1 addition & 1 deletion container/modlauncher8/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
}

val jar by tasks.registering(ShadowJar::class) {
destinationDirectory.set(project.buildDir.resolve("libs"))
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveBaseName.set("container-${project.name}")

configureModLauncherContainerJar(stage0)
Expand Down
2 changes: 1 addition & 1 deletion container/modlauncher9/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
}

val jar by tasks.registering(ShadowJar::class) {
destinationDirectory.set(project.buildDir.resolve("libs"))
destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveBaseName.set("container-${project.name}")

configureModLauncherContainerJar(stage0)
Expand Down
1 change: 1 addition & 0 deletions integrationTest/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'java-library'

dependencies {
api("org.junit.jupiter:junit-jupiter:5.7.2")
runtimeOnly("org.junit.platform:junit-platform-launcher")

implementation("org.ow2.asm:asm-commons:5.0")
implementation("com.google.guava:guava:21.0")
Expand Down
14 changes: 9 additions & 5 deletions integrationTest/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import java.util.function.Supplier
import javax.inject.Inject

repositories {
maven { url "https://maven.fabricmc.net/" }
interface Injected {
@Inject ArchiveOperations getArchiveOps()
}

def injected = objects.newInstance(Injected.class)
def archiveOps = injected.getArchiveOps()

sourceSets {
exampleMod
essential
Expand Down Expand Up @@ -151,15 +155,15 @@ tasks.register("essentialJijijJar", Jar) {
(1..5).each { i ->
def stage2Task = tasks.register("stage2V${i}Jar", Jar) {
archiveBaseName.set(name)
from(evaluationDependsOn(':stage2:fabric').tasks.jar.archiveFile.map { zipTree(it) })
from(evaluationDependsOn(':stage2:fabric').tasks.jar.archiveFile.map { archiveOps.zipTree(it) })
// Dummy attribute so they all have different hashes
manifest {
attributes "Implementation-Version": "$i"
}
}
def stage3Task = tasks.register("stage3V${i}Jar", Jar) {
archiveBaseName.set(name)
from(tasks.essentialJar.archiveFile.map { zipTree(it) })
from(tasks.essentialJar.archiveFile.map { archiveOps.zipTree(it) })
manifest {
// Dummy attribute so they all have different hashes
attributes "Implementation-Version": "$i"
Expand All @@ -171,7 +175,7 @@ tasks.register("essentialJijijJar", Jar) {
}
tasks.register("exampleBundledModJar$i", Jar) {
archiveBaseName.set(name)
from(tasks.exampleModJar.archiveFile.map { zipTree(it) })
from(tasks.exampleModJar.archiveFile.map { archiveOps.zipTree(it) })

def stage2Jar = stage2Task.get().archiveFile
def stage3Jar = stage3Task.get().archiveFile
Expand Down
37 changes: 20 additions & 17 deletions integrationTest/launchwrapper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ import java.util.function.Supplier
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipOutputStream
import javax.inject.Inject

plugins {
id "com.github.johnrengelman.shadow" version "7.1.2" apply false
id "com.gradleup.shadow" version "8.3.9" apply false
}

repositories {
maven { url "https://maven.minecraftforge.net/" }
maven { url "https://repo.spongepowered.org/maven" }
interface Injected {
@Inject ArchiveOperations getArchiveOps()
}

def injected = objects.newInstance(Injected.class)
def archiveOps = injected.getArchiveOps()

sourceSets {
exampleMod
example2Mod
Expand Down Expand Up @@ -126,9 +129,9 @@ def integrationTest = tasks.register("integrationTest", Test) {
}
check.dependsOn(integrationTest)

def includeMixin(AbstractArchiveTask task, Configuration mixin) {
def includeMixin = { AbstractArchiveTask task, Configuration mixin ->
task.dependsOn(mixin)
task.from({ mixin.collect { zipTree(it) } }) {
task.from({ mixin.collect { archiveOps.zipTree(it) } }) {
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
}
}
Expand All @@ -137,7 +140,7 @@ def configureExampleModJar = { String tweaker, Configuration mixin = null, exclu
archiveBaseName.set(task.name)
from(sourceSets.exampleMod.output)
dependsOn(configurations.exampleModRuntimeClasspath)
from({ configurations.exampleModRuntimeClasspath.collect { zipTree(it) } }) {
from({ configurations.exampleModRuntimeClasspath.collect { archiveOps.zipTree(it) } }) {
if (excludes != null) {
excludes()
}
Expand All @@ -161,7 +164,7 @@ def configureExample2ModJar = { String tweaker, Configuration mixin = null -> re
archiveBaseName.set(name)
from(sourceSets.example2Mod.output)
dependsOn(configurations.example2ModRuntimeClasspath)
from({ configurations.example2ModRuntimeClasspath.collect { zipTree(it) } })
from({ configurations.example2ModRuntimeClasspath.collect { archiveOps.zipTree(it) } })

manifest {
attributes "FMLCorePlugin": "com.example.mod2.ExampleCoreMod",
Expand Down Expand Up @@ -242,15 +245,15 @@ tasks.register("exampleRelocatedModJar", com.github.jengelman.gradle.plugins.sha
(1..5).each { i ->
def stage2Task = tasks.register("stage2V${i}Jar", Jar) {
archiveBaseName.set(name)
from(evaluationDependsOn(':stage2:launchwrapper').tasks.jar.archiveFile.map { zipTree(it) })
from(evaluationDependsOn(':stage2:launchwrapper').tasks.jar.archiveFile.map { archiveOps.zipTree(it) })
manifest {
attributes "Name": "gg/essential/loader/stage2/"
attributes "Implementation-Version": "$i"
}
}
def stage1Task = tasks.register("stage1V${i}Jar", Jar) {
archiveBaseName.set(name)
from(evaluationDependsOn(':stage1:launchwrapper').tasks.jar.archiveFile.map { zipTree(it) }) {
from(evaluationDependsOn(':stage1:launchwrapper').tasks.jar.archiveFile.map { archiveOps.zipTree(it) }) {
exclude("gg/essential/loader/stage1/stage2.jar")
}
from(stage2Task.flatMap { it.archiveFile }) {
Expand All @@ -264,7 +267,7 @@ tasks.register("exampleRelocatedModJar", com.github.jengelman.gradle.plugins.sha
}
def stage3Task = tasks.register("stage3V${i}Jar", Jar) {
archiveBaseName.set(name)
from(tasks.essentialJar.archiveFile.map { zipTree(it) })
from(tasks.essentialJar.archiveFile.map { archiveOps.zipTree(it) })
from(stage1Task.flatMap { it.archiveFile }) {
into("gg/essential/loader/stage0")
rename { "stage1.jar" }
Expand Down Expand Up @@ -318,15 +321,15 @@ tasks.register("essentialWithAsm52Jar", Jar) {
includeMixin(it, configurations.mixin07)

dependsOn(configurations.asm52)
from({ configurations.asm52.collect { zipTree(it) } })
from({ configurations.asm52.collect { archiveOps.zipTree(it) } })
}

tasks.register("essentialWithDummyStage1", Jar) {
archiveBaseName.set("essential-with-dummy-stage1")
from(sourceSets.essential.output)
includeMixin(it, configurations.mixin07)

from(tasks.named("dummyStage1Jar").map { it.outputs }) {
from(tasks.named("dummyStage1Jar").map { it.archiveFile }) {
rename { "gg/essential/loader/stage0/stage1.jar" }
}
}
Expand All @@ -353,10 +356,10 @@ tasks.register("dummyStage3Jar", Jar) {

tasks.register("dummyStage3DiffJar", Jar) {
archiveBaseName.set("dummyStage3Diff")
from(essentialJar.archiveFile.map { zipTree(it) }) {
from(essentialJar.archiveFile.map { archiveOps.zipTree(it) }) {
into("-")
}
from(dummyStage3Jar.archiveFile.map { zipTree(it) }) {
from(dummyStage3Jar.archiveFile.map { archiveOps.zipTree(it) }) {
into("~")
}
}
Expand All @@ -366,7 +369,7 @@ tasks.register("forge10808Jar", Jar) {

from(sourceSets.minecraft10808.output)
dependsOn(configurations.forge10808Runtime)
from({ configurations.forge10808Runtime.collect { zipTree(it) } }) {
from({ configurations.forge10808Runtime.collect { archiveOps.zipTree(it) } }) {
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
exclude 'META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat'
exclude 'net/minecraftforge/fml/common/launcher/TerminalTweaker.class'
Expand All @@ -378,7 +381,7 @@ tasks.register("forge11202Jar", Jar) {

from(sourceSets.minecraft11202.output)
dependsOn(configurations.forge11202Runtime)
from({ configurations.forge11202Runtime.collect { zipTree(it) } }) {
from({ configurations.forge11202Runtime.collect { archiveOps.zipTree(it) } }) {
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
exclude 'META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat'
exclude 'net/minecraftforge/fml/common/launcher/TerminalTweaker.class'
Expand Down
13 changes: 5 additions & 8 deletions mixin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import essential.CompatMixinTask
import gg.essential.gradle.util.prebundle
import gg.essential.gradle.util.RelocationTransform.Companion.registerRelocationAttribute
import org.gradle.api.file.ArchiveOperations
import org.gradle.kotlin.dsl.support.serviceOf

plugins {
id("java-library")
Expand All @@ -16,12 +18,6 @@ val asmVersion = "5.2"
version = "$patchesVersion+mixin.$mixinVersion"
java.toolchain.languageVersion.set(JavaLanguageVersion.of(8))

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

val relocated = registerRelocationAttribute("essential-guava21-relocated") {
relocate("com.google.common", "gg.essential.lib.guava21")
relocate("com.google.thirdparty.publicsuffix", "gg.essential.lib.guava21.publicsuffix")
Expand Down Expand Up @@ -63,11 +59,12 @@ tasks.processResources {
val patchedJar by tasks.registering(CompatMixinTask::class) {
mixinClasses.from(sourceSets.main.map { it.output })
input.set(fatMixin.files.single())
output.set(buildDir.resolve("patched.jar"))
output.set(layout.buildDirectory.file("patched.jar"))
}

tasks.jar {
from(patchedJar.flatMap { it.output }.map { zipTree(it) }) {
val archiveOps = project.serviceOf<ArchiveOperations>()
from(patchedJar.flatMap { it.output }.map { archiveOps.zipTree(it) }) {
// Signatures were invalidated by patching
exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
// Legacy Forge chokes on these (and they are useless for it anyway cause it only supports Java 8)
Expand Down
13 changes: 12 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ pluginManagement {
}
}

dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.PREFER_SETTINGS
repositories {
mavenCentral()
maven(url = "https://maven.fabricmc.net/")
maven(url = "https://repo.spongepowered.org/maven")
maven(url = "https://maven.neoforged.net/releases")
maven(url = "https://maven.minecraftforge.net/")
maven(url = "https://libraries.minecraft.net/")
}
}

includeBuild("build-logic")

include(":container:fabric")
Expand Down Expand Up @@ -47,4 +59,3 @@ include(":mixin")
include(":integrationTest:common")
include(":integrationTest:fabric")
include(":integrationTest:launchwrapper")
include(":integrationTest:modlauncher")
19 changes: 13 additions & 6 deletions stage0/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
version = "1.3.0"

interface Injected {
@javax.inject.Inject ArchiveOperations getArchiveOps()
}

configure(subprojects.findAll { it.name != "common" && it.name != "modlauncher" }) {
apply plugin: 'maven-publish'

Expand All @@ -18,11 +22,14 @@ configure(subprojects.findAll { it.name != "common" && it.name != "modlauncher"
}
}

def injected = objects.newInstance(Injected.class)
def archiveOps = injected.getArchiveOps()

jar {
dependsOn configurations.bundle
from { configurations.bundle.collect { zipTree(it) } }
from { configurations.bundle.collect { archiveOps.zipTree(it) } }

from(evaluationDependsOn(":stage1:$variant").tasks.named("jar").map { it.outputs }) {
from(evaluationDependsOn(":stage1:$variant").tasks.named("jar").map { it.archiveFile }) {
rename { "gg/essential/loader/stage0/stage1.jar" }
}
}
Expand All @@ -38,12 +45,12 @@ configure(subprojects.findAll { it.name != "common" && it.name != "modlauncher"
repositories {
if (project.hasProperty("nexus_user")) {
maven {
name 'nexus'
url "https://repo.essential.gg/repository/maven-releases/"
name = "nexus"
url = "https://repo.essential.gg/repository/maven-releases/"

credentials {
username project.nexus_user
password project.nexus_password
username = project.nexus_user
password = project.nexus_password
}
}
}
Expand Down
Loading