Skip to content

Commit 8de12f3

Browse files
Technici4nshartte
andauthored
Add option to disable the decompilation+recompilation pipeline (#304)
Co-authored-by: Sebastian Hartte <[email protected]>
1 parent 5e75c91 commit 8de12f3

File tree

19 files changed

+208
-42
lines changed

19 files changed

+208
-42
lines changed

.github/workflows/build-prs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ jobs:
2626

2727
test-project:
2828
strategy:
29+
max-parallel: 6
2930
matrix:
3031
os: [ubuntu-latest, windows-latest]
3132
project: [testproject, legacytest]
33+
recomp: ["recomp", "no recomp"]
3234
runs-on: ${{ matrix.os }}
33-
name: Test ${{ matrix.project }} on ${{ matrix.os }}
35+
name: Test ${{ matrix.project }} on ${{ matrix.os }} (${{ matrix.recomp }})
36+
env:
37+
CI: ${{ matrix.recomp == 'no recomp' }}
3438
steps:
3539
- name: Checkout project sources
3640
uses: neoforged/actions/checkout@main

LEGACY.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ legacyForge {
103103
}
104104
```
105105

106+
## Disabling Decompilation and Recompilation
107+
As of MDG Legacy 2.0.124, the decompilation/recompilation pipeline can be disabled, similarly to the regular plugin.
108+
To disable it in CI, use the following:
109+
```groovy
110+
legacyForge {
111+
enable {
112+
forgeVersion = "..." // or mcpVersion = "..." if running in Vanilla mode
113+
// Disable recompilation if the "CI" environment variable is set to true. It is automatically set by GitHub Actions.
114+
disableRecompilation = System.getenv("CI") == "true"
115+
}
116+
}
117+
```
118+
106119
## Mixins
107120

108121
You need to create so-called "refmaps" for Mixin, which convert the names you used to declare injection points and reference other parts of Minecraft code to the names used at runtime (SRG).

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ neoForge {
108108
}
109109
```
110110

111+
## Disabling Decompilation and Recompilation
112+
By default, MDG will use the [NeoForm](https://github.com/neoforged/NeoForm) decompilation/recompilation pipeline to produce
113+
Minecraft sources and a matching compiled game jar. This leads to a great debugging experience, at the cost of longer setup times.
114+
115+
As of MDG 2.0.124, an alternative pipeline can be used, which will skip decompilation and recompilation entirely!
116+
We recommend leaving recompilation on by default, but disabling it when running on CI such as GitHub Actions.
117+
118+
To do so, replace:
119+
```groovy
120+
neoForge {
121+
version = "..." // or neoFormVersion = "..."
122+
}
123+
```
124+
By:
125+
```groovy
126+
neoForge {
127+
enable {
128+
version = "..." // or neoFormVersion = "..."
129+
// Disable recompilation if the "CI" environment variable is set to true. It is automatically set by GitHub Actions.
130+
disableRecompilation = System.getenv("CI") == "true"
131+
}
132+
}
133+
```
134+
111135
## Common Issues
112136

113137
### Clicking "Attach Sources" does nothing when viewing a Minecraft class (IntelliJ IDEA)

legacytest/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ java {
1313
}
1414

1515
legacyForge {
16-
mcpVersion = '1.19.2'
16+
enable {
17+
mcpVersion = '1.19.2'
18+
disableRecompilation = System.getenv("CI") == "true"
19+
}
1720
}
1821

1922
publishing {

legacytest/forge/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44
}
55

66
repositories {
7-
mavenLocal()
87
maven {
98
name = "Jared's maven"
109
url = "https://maven.blamejared.com/"
@@ -33,7 +32,10 @@ dependencies {
3332
}
3433

3534
legacyForge {
36-
version = '1.20.1-47.3.12'
35+
enable {
36+
forgeVersion = '1.20.1-47.3.12'
37+
disableRecompilation = System.getenv("CI") == "true"
38+
}
3739
runs {
3840
client {
3941
client()

legacytest/forge/src/main/java/mymod/MyMod.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package mymod;
22

33
import net.minecraft.DetectedVersion;
4+
import net.minecraft.core.BlockPos;
5+
import net.minecraft.server.level.ServerLevel;
6+
import net.minecraft.world.level.block.EnderChestBlock;
7+
import net.minecraft.world.level.block.state.BlockBehaviour;
48
import net.minecraftforge.fml.common.Mod;
59

610
@Mod("mymod")
@@ -9,6 +13,13 @@ public void run() {
913
DetectedVersion.tryDetectVersion();
1014
}
1115

16+
public static void doStuff() {
17+
// Test our AT
18+
ServerLevel.END_SPAWN_POINT = new BlockPos(1, 2, 3);
19+
// Test a Forge AT (in a class that is not binpatched)
20+
var block = new EnderChestBlock(BlockBehaviour.Properties.of());
21+
}
22+
1223
@javax.annotation.Nullable
1324
private static Object javaxNullableTest() {
1425
return null;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public-f net.minecraft.server.level.ServerLevel f_8562_ # END_SPAWN_POINT

legacytest/forgedownstream/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ dependencies {
1616
}
1717

1818
legacyForge {
19-
version = '1.20.1-47.3.0'
19+
enable {
20+
forgeVersion = '1.20.1-47.3.0'
21+
disableRecompilation = System.getenv("CI") == "true"
22+
}
2023
}
2124

2225
var copyJarJar = tasks.register('copyJarJar', Copy) {

src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeModdingSettings.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public abstract class LegacyForgeModdingSettings {
2020

2121
private Set<SourceSet> enabledSourceSets = new HashSet<>();
2222

23+
private boolean disableRecompilation = false;
24+
2325
private boolean obfuscateJar = true;
2426

2527
@Inject
@@ -78,6 +80,21 @@ public void setEnabledSourceSets(Set<SourceSet> enabledSourceSets) {
7880
this.enabledSourceSets = enabledSourceSets;
7981
}
8082

83+
/**
84+
* {@code true} if MDG should skip the NeoForm decompilation/recompilation pipeline,
85+
* and instead apply transforms on the .class files and use binary patches.
86+
* This leads to a faster setup since Minecraft doesn't need to be decompiled,
87+
* however source files will not be available.
88+
* {@code false} by default.
89+
*/
90+
public boolean isDisableRecompilation() {
91+
return disableRecompilation;
92+
}
93+
94+
public void setDisableRecompilation(boolean disableRecompilation) {
95+
this.disableRecompilation = disableRecompilation;
96+
}
97+
8198
/**
8299
* {@return true if default reobfuscation task should be created}
83100
*/

src/legacy/java/net/neoforged/moddevgradle/legacyforge/internal/LegacyForgeModDevPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ public void enable(Project project, LegacyForgeModdingSettings settings, LegacyF
153153
artifactNamingStrategy,
154154
configurations.getByName(DataFileCollections.CONFIGURATION_ACCESS_TRANSFORMERS),
155155
configurations.getByName(DataFileCollections.CONFIGURATION_INTERFACE_INJECTION_DATA),
156-
versionCapabilities);
156+
versionCapabilities,
157+
settings.isDisableRecompilation());
157158

158159
var runs = ModDevRunWorkflow.create(
159160
project,

0 commit comments

Comments
 (0)