Skip to content

Commit 5fbf575

Browse files
authored
Add a separate reobf gradle configuration (#2885)
* Add a separate reobf gradle configuration * Remove ArtifactPriority system * PR feedback notes
1 parent e4a3fb4 commit 5fbf575

File tree

4 files changed

+28
-44
lines changed

4 files changed

+28
-44
lines changed
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import buildlogic.ArtifactPriority
21
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
32
import org.gradle.kotlin.dsl.named
43

@@ -9,12 +8,3 @@ plugins {
98
paperweight {
109
reobfArtifactConfiguration = ReobfArtifactConfiguration.MOJANG_PRODUCTION
1110
}
12-
13-
configurations.named("runtimeElements") {
14-
attributes {
15-
attribute(
16-
ArtifactPriority.ATTRIBUTE,
17-
objects.named(ArtifactPriority.PRIMARY),
18-
)
19-
}
20-
}
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import buildlogic.ArtifactPriority
21
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
3-
import io.papermc.paperweight.util.constants.REOBF_CONFIG
42

53
plugins {
64
id("buildlogic.adapter")
@@ -13,12 +11,3 @@ paperweight {
1311
tasks.named("assemble") {
1412
dependsOn("reobfJar")
1513
}
16-
17-
configurations.named(REOBF_CONFIG) {
18-
attributes {
19-
attribute(
20-
ArtifactPriority.ATTRIBUTE,
21-
objects.named(ArtifactPriority.PRIMARY),
22-
)
23-
}
24-
}

build-logic/src/main/kotlin/buildlogic/ArtifactPriority.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.

worldedit-bukkit/build.gradle.kts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import buildlogic.ArtifactPriority
21
import buildlogic.internalVersion
32
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
43
import io.papermc.paperweight.userdev.attribute.Obfuscation
@@ -26,18 +25,25 @@ configurations.named("testImplementation") {
2625
val adaptersScope = configurations.dependencyScope("adaptersScope") {
2726
description = "Adapters to include in the JAR"
2827
}
28+
val adaptersReobfScope = configurations.dependencyScope("adaptersReobfScope") {
29+
description = "Reobfuscated adapters to include in the JAR"
30+
}
31+
2932
val adapters = configurations.resolvable("adapters") {
3033
extendsFrom(adaptersScope.get())
3134
description = "Adapters to include in the JAR (resolvable)"
3235
shouldResolveConsistentlyWith(configurations["runtimeClasspath"])
3336
attributes {
34-
if ((project.findProperty("enginehub.obf.none") as String?).toBoolean()) {
35-
// If we're configured to not output obfuscated, request none
36-
attribute(Obfuscation.OBFUSCATION_ATTRIBUTE, objects.named(Obfuscation.NONE))
37-
} else {
38-
// Otherwise, use the primary artifact, which may or may not be obfuscated
39-
attribute(ArtifactPriority.ATTRIBUTE, objects.named(ArtifactPriority.PRIMARY))
40-
}
37+
attribute(Obfuscation.OBFUSCATION_ATTRIBUTE, objects.named(Obfuscation.NONE))
38+
}
39+
}
40+
41+
val adaptersReobf = configurations.resolvable("adaptersReobf") {
42+
extendsFrom(adaptersReobfScope.get())
43+
description = "Reobfuscated adapters to include in the JAR (resolvable)"
44+
shouldResolveConsistentlyWith(configurations["runtimeClasspath"])
45+
attributes {
46+
attribute(Obfuscation.OBFUSCATION_ATTRIBUTE, objects.named(Obfuscation.OBFUSCATED))
4147
}
4248
}
4349

@@ -67,6 +73,9 @@ dependencies {
6773
project.project(":worldedit-bukkit:adapters").subprojects.forEach {
6874
"adaptersScope"(project(it.path))
6975
}
76+
listOf("1.21.3", "1.21.4", "1.21.5", "1.21.6", "1.21.9", "1.21.11").forEach {
77+
"adaptersReobfScope"(project(":worldedit-bukkit:adapters:adapter-$it"))
78+
}
7079
}
7180

7281
tasks.named<Copy>("processResources") {
@@ -78,7 +87,15 @@ tasks.named<Copy>("processResources") {
7887
}
7988
}
8089

90+
tasks.register<ShadowJar>("shadeReobfAdapters") {
91+
archiveClassifier.set("reobf-adapters")
92+
configurations.add(adaptersReobf.get())
93+
94+
relocate("com.sk89q.worldedit.bukkit.adapter.impl", "com.sk89q.worldedit.bukkit.adapter.impl.reobf")
95+
}
96+
8197
tasks.named<ShadowJar>("shadowJar") {
98+
from(tasks.named("shadeReobfAdapters"))
8299
configurations.add(adapters.get())
83100
dependencies {
84101
// In tandem with not bundling log4j, we shouldn't relocate base package here.
@@ -108,6 +125,9 @@ tasks.named<ShadowJar>("shadowJar") {
108125
exclude(dependency("${it.group}:${it.name}"))
109126
}
110127
}
128+
manifest {
129+
attributes["paperweight-mappings-namespace"] = "mojang"
130+
}
111131
}
112132

113133
tasks.named("assemble").configure {

0 commit comments

Comments
 (0)