Skip to content

Commit a4e9363

Browse files
committed
closer now, still some wrong checksums...
1 parent ccb215d commit a4e9363

File tree

5 files changed

+666
-22
lines changed

5 files changed

+666
-22
lines changed

src/main/java/net/fabricmc/loom/configuration/providers/forge/MinecraftPatchedProvider.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import dev.architectury.tinyremapper.OutputConsumerPath;
6969
import dev.architectury.tinyremapper.TinyRemapper;
7070
import net.minecraftforge.binarypatcher.ConsoleTool;
71+
import net.minecraftforge.gradle.tasks.MergeJars;
7172
import org.apache.commons.io.output.NullOutputStream;
7273
import org.gradle.api.Project;
7374
import org.gradle.api.file.ConfigurableFileCollection;
@@ -347,11 +348,21 @@ private void produceSrgJar(boolean official, Path clientJar, Path serverJar) thr
347348

348349
boolean isSrg = getExtension().getMcpConfigProvider().isSRG();
349350

350-
// ThreadingUtils.run(() -> {
351-
Files.copy(SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "client", mcLibs, clientJar, tmpSrg, isSrg), minecraftClientSrgJar.toPath());
352-
// }, () -> {
353-
Files.copy(SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "server", mcLibs, serverJar, tmpSrg, isSrg), minecraftServerSrgJar.toPath());
354-
// });
351+
Path[] clientJarOut = new Path[] { null };
352+
Path[] serverJarOut = new Path[] { null };
353+
354+
ThreadingUtils.run(() -> {
355+
clientJarOut[0] = SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "client", mcLibs, clientJar, tmpSrg, isSrg);
356+
}, () -> {
357+
serverJarOut[0] = SpecialSourceExecutor.produceSrgJar(getExtension().getMcpConfigProvider().getRemapAction(), getProject(), "server", mcLibs, serverJar, tmpSrg, isSrg);
358+
});
359+
360+
if (isSrg) {
361+
new MergeJars().processJar(clientJarOut[0].toFile(), serverJarOut[0].toFile(), minecraftClientSrgJar);
362+
} else {
363+
Files.copy(clientJarOut[0], minecraftClientSrgJar.toPath());
364+
Files.copy(serverJarOut[0], minecraftServerSrgJar.toPath());
365+
}
355366
}
356367

357368
private Path getToSrgMappings() throws IOException {

src/main/java/net/fabricmc/loom/util/srg/SpecialSourceExecutor.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.stream.Collectors;
3636

3737
import com.google.common.base.Stopwatch;
38+
import net.minecraftforge.gradle.tasks.MergeJars;
3839
import org.apache.commons.io.output.NullOutputStream;
3940
import org.gradle.api.Project;
4041
import org.gradle.api.logging.LogLevel;
@@ -113,7 +114,7 @@ public static Path produceSrgJar(RemapAction remapAction, Project project, Strin
113114
}
114115

115116
Path output = extension.getFiles().getProjectBuildCache().toPath().resolve(officialJar.getFileName().toString().substring(0, officialJar.getFileName().toString().length() - 4) + "-srg-output.jar");
116-
Files.deleteIfExists(output);
117+
// Files.deleteIfExists(output);
117118
stopwatch = Stopwatch.createStarted();
118119

119120
project.getLogger().info(stripped.toString());
@@ -123,32 +124,36 @@ public static Path produceSrgJar(RemapAction remapAction, Project project, Strin
123124

124125
Path workingDir = tmpDir();
125126

126-
project.javaexec(spec -> {
127-
spec.setArgs(args);
128-
spec.setClasspath(remapAction.getClasspath());
129-
spec.workingDir(workingDir.toFile());
130-
spec.getMainClass().set(remapAction.getMainClass());
127+
if (!isSrg) {
128+
project.javaexec(spec -> {
129+
spec.setArgs(args);
130+
spec.setClasspath(remapAction.getClasspath());
131+
spec.workingDir(workingDir.toFile());
132+
spec.getMainClass().set(remapAction.getMainClass());
131133

132-
// if running with INFO or DEBUG logging
133-
if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS
134+
// if running with INFO or DEBUG logging
135+
if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS
134136
|| project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.LIFECYCLE) < 0) {
135-
spec.setStandardOutput(System.out);
136-
spec.setErrorOutput(System.err);
137-
} else {
138-
spec.setStandardOutput(NullOutputStream.NULL_OUTPUT_STREAM);
139-
spec.setErrorOutput(NullOutputStream.NULL_OUTPUT_STREAM);
140-
}
141-
}).rethrowFailure().assertNormalExitValue();
137+
spec.setStandardOutput(System.out);
138+
spec.setErrorOutput(System.err);
139+
} else {
140+
spec.setStandardOutput(NullOutputStream.NULL_OUTPUT_STREAM);
141+
spec.setErrorOutput(NullOutputStream.NULL_OUTPUT_STREAM);
142+
}
143+
}).rethrowFailure().assertNormalExitValue();
144+
} else {
145+
Files.copy(stripped, output, StandardCopyOption.REPLACE_EXISTING);
146+
}
142147

143148
project.getLogger().lifecycle(":remapped minecraft (" + remapAction + ", " + side + ", official -> mojang) in " + stopwatch.stop());
144149

145-
Files.deleteIfExists(stripped);
150+
// Files.deleteIfExists(stripped);
146151

147152
Path tmp = tmpFile();
148153
Files.deleteIfExists(tmp);
149154
Files.copy(output, tmp);
150155

151-
Files.deleteIfExists(output);
156+
// Files.deleteIfExists(output);
152157
return tmp;
153158
}
154159

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Forge Mod Loader
3+
* Copyright (c) 2012-2013 cpw.
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the GNU Lesser Public License v2.1
6+
* which accompanies this distribution, and is available at
7+
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
8+
*
9+
* Contributors:
10+
* cpw - implementation
11+
*/
12+
13+
package net.minecraftforge.fml.relauncher;
14+
15+
public enum Side {
16+
17+
/**
18+
* The client side. Specifically, an environment where rendering capability exists.
19+
* Usually in the game client.
20+
*/
21+
CLIENT,
22+
/**
23+
* The server side. Specifically, an environment where NO rendering capability exists.
24+
* Usually on the dedicated server.
25+
*/
26+
SERVER;
27+
28+
/**
29+
* @return If this is the server environment
30+
*/
31+
public boolean isServer()
32+
{
33+
return !isClient();
34+
}
35+
36+
/**
37+
* @return if this is the Client environment
38+
*/
39+
public boolean isClient()
40+
{
41+
return this == CLIENT;
42+
}
43+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Forge Mod Loader
3+
* Copyright (c) 2012-2013 cpw.
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the GNU Lesser Public License v2.1
6+
* which accompanies this distribution, and is available at
7+
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
8+
*
9+
* Contributors:
10+
* cpw - implementation
11+
*/
12+
13+
package net.minecraftforge.fml.relauncher;
14+
15+
import java.lang.annotation.ElementType;
16+
import java.lang.annotation.Retention;
17+
import java.lang.annotation.RetentionPolicy;
18+
import java.lang.annotation.Target;
19+
20+
21+
/**
22+
*
23+
* Stolen from FML for use with merging the jars.
24+
*
25+
* @author cpw
26+
*
27+
*/
28+
@Retention(RetentionPolicy.RUNTIME)
29+
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
30+
public @interface SideOnly
31+
{
32+
public Side value();
33+
}

0 commit comments

Comments
 (0)