build: Compile against and shade the filtered jar (#9747)

* Compile against & shade the filtered jar

* Move check for if the paper asset root needs to be pushed

* Don't disable incremental compilation

* Remove mavenLocal

* use paperweight release
This commit is contained in:
Jason Penilla 2024-04-04 17:12:05 -07:00
parent 44336b8510
commit 61dc3d0b17
3 changed files with 33 additions and 45 deletions

View File

@ -11,7 +11,7 @@ plugins {
java java
`maven-publish` `maven-publish`
id("com.github.johnrengelman.shadow") version "8.1.1" apply false id("com.github.johnrengelman.shadow") version "8.1.1" apply false
id("io.papermc.paperweight.core") version "1.5.12" id("io.papermc.paperweight.core") version "1.5.13"
} }
allprojects { allprojects {

View File

@ -41,18 +41,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
) )
for (tld in setOf("net", "com", "org")) { for (tld in setOf("net", "com", "org")) {
attributes("$tld/bukkit", "Sealed" to true) attributes("$tld/bukkit", "Sealed" to true)
@@ -0,0 +0,0 @@ tasks.jar {
}
}
+tasks.compileJava {
+ // incremental compilation is currently broken due to patched files having compiled counterparts already on the compile classpath
+ options.setIncremental(false)
+}
+
publishing {
publications.create<MavenPublication>("maven") {
artifact(tasks.shadowJar)
@@ -0,0 +0,0 @@ tasks.shadowJar { @@ -0,0 +0,0 @@ tasks.shadowJar {
} }
} }
@ -72,20 +60,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class")
useJUnitPlatform() useJUnitPlatform()
@@ -0,0 +0,0 @@ tasks.registerRunTask("runReobf") { @@ -0,0 +0,0 @@ tasks.registerRunTask("runReobf") {
classpath(runtimeClasspathWithoutVanillaServer)
}
+val runtimeClasspathForRunDev = sourceSets.main.flatMap { src ->
+ src.runtimeClasspath.elements.map { elements ->
+ elements.filterNot { file -> file.asFile.endsWith("minecraft.jar") }
+ }
+}
tasks.registerRunTask("runDev") { tasks.registerRunTask("runDev") {
description = "Spin up a non-relocated Mojang-mapped test server" description = "Spin up a non-relocated Mojang-mapped test server"
- classpath(sourceSets.main.map { it.runtimeClasspath }) classpath(sourceSets.main.map { it.runtimeClasspath })
+ classpath(tasks.filterProjectDir.flatMap { it.outputJar }) + jvmArgs("-DPaper.pushPaperAssetsRoot=true")
+ classpath(runtimeClasspathForRunDev)
+ jvmArgs("-DPaper.isRunDev=true")
} }
diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -99,27 +77,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private final String namespace; private final String namespace;
private final String path; private final String path;
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java diff --git a/src/main/java/net/minecraft/server/packs/VanillaPackResourcesBuilder.java b/src/main/java/net/minecraft/server/packs/VanillaPackResourcesBuilder.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/Main.java --- a/src/main/java/net/minecraft/server/packs/VanillaPackResourcesBuilder.java
+++ b/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/packs/VanillaPackResourcesBuilder.java
@@ -0,0 +0,0 @@ public class Main { @@ -0,0 +0,0 @@ public class VanillaPackResourcesBuilder {
*/ // CraftBukkit end
try { public VanillaPackResourcesBuilder applyDevelopmentConfig() {
+ // Paper start developmentConfig.accept(this);
+ if (Boolean.getBoolean("Paper.isRunDev")) { + if (Boolean.getBoolean("Paper.pushPaperAssetsRoot")) {
+ net.minecraft.server.packs.VanillaPackResourcesBuilder.developmentConfig = builder -> { + try {
+ try { + this.pushAssetPath(net.minecraft.server.packs.PackType.SERVER_DATA, net.minecraft.server.packs.VanillaPackResourcesBuilder.safeGetPath(java.util.Objects.requireNonNull(
+ builder.pushAssetPath(net.minecraft.server.packs.PackType.SERVER_DATA, net.minecraft.server.packs.VanillaPackResourcesBuilder.safeGetPath(java.util.Objects.requireNonNull(Main.class.getResource("/data/.paperassetsroot"), "Missing required .paperassetsroot file").toURI()).getParent()); + // Important that this is a patched class
+ } catch (java.net.URISyntaxException | IOException ex) { + VanillaPackResourcesBuilder.class.getResource("/data/.paperassetsroot"), "Missing required .paperassetsroot file").toURI()).getParent());
+ throw new RuntimeException(ex); + } catch (java.net.URISyntaxException | IOException ex) {
+ } + throw new RuntimeException(ex);
+ };
+ } + }
+ // Paper end + }
return this;
Path path = (Path) optionset.valueOf("pidFile"); // CraftBukkit }
diff --git a/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java b/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java diff --git a/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java b/src/main/java/net/minecraft/server/packs/repository/ServerPacksSource.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -163,3 +139,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
diff --git a/src/main/resources/data/.paperassetsroot b/src/main/resources/data/.paperassetsroot diff --git a/src/main/resources/data/.paperassetsroot b/src/main/resources/data/.paperassetsroot
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase {
public static final Registry<Biome> BIOMES;
static {
+ System.setProperty("Paper.pushPaperAssetsRoot", "true"); // Paper
SharedConstants.tryDetectVersion();
Bootstrap.bootStrap();
// Populate available packs

View File

@ -16,8 +16,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
val craftbukkitPackageVersion = "1_20_R3" // Paper val craftbukkitPackageVersion = "1_20_R3" // Paper
@@ -0,0 +0,0 @@ tasks.compileJava { @@ -0,0 +0,0 @@ tasks.jar {
options.setIncremental(false) }
} }
+// Paper start - compile tests with -parameters for better junit parameterized test names +// Paper start - compile tests with -parameters for better junit parameterized test names