Skip to content

Commit 01f42a3

Browse files
committed
Optimize deps for reobfJar
1 parent 8fc508d commit 01f42a3

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/main/groovy/net/minecraftforge/forgedev/ForgeDevExtension.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ private void setup(ForgeDevPlugin plugin, Project project) {
123123
Util.runFirst(project, syncMavenizer);
124124
Util.runFirst(project, syncMavenizerForExtra);
125125
Util.runFirst(project, syncMappingsMaven);
126+
var minecraftDepsConfiguration = project.getConfigurations().detachedConfiguration();
126127
var mappingsConfiguration = project.getConfigurations().detachedConfiguration();
127128
var mappingsZipFile = this.getProviders().provider(mappingsConfiguration::getSingleFile);
128129

@@ -210,8 +211,7 @@ private void setup(ForgeDevPlugin plugin, Project project) {
210211

211212
var reobfJar = tasks.register("reobfJar", LegacyReobfuscateJar.class, task -> {
212213
task.getInput().set(jar.flatMap(Jar::getArchiveFile));
213-
// TODO Optimize this to use a detached configuration
214-
task.getLibraries().from(project.getConfigurations().named(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
214+
task.getLibraries().from(minecraftDepsConfiguration);
215215
task.getOutput().convention(task.getDefaultOutputFile());
216216
});
217217

@@ -330,6 +330,7 @@ private void setup(ForgeDevPlugin plugin, Project project) {
330330
project.getDependencies().add(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, minecraftDependency);
331331
project.getDependencies().add(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, minecraftExtraDependency);
332332
project.getDependencies().add(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, mappingsDependency);
333+
minecraftDepsConfiguration.withDependencies(d -> d.add(minecraftDependency));
333334
mappingsConfiguration.withDependencies(d -> d.add(mappingsDependency));
334335

335336
// Add the patched source as a source dir during afterEvaluate, to not be overwritten by buildscripts

src/main/groovy/net/minecraftforge/forgedev/tasks/obfuscation/LegacyReobfuscateJar.groovy

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ abstract class LegacyReobfuscateJar extends ToolExec {
101101
}
102102

103103
work.submit(Action) {
104+
it.logLevel.set(standardOutputLogLevel)
105+
104106
it.srg.set(this.srg)
105107
it.output.set(this.output)
106108
it.temporaryOutput.set(this.temporaryOutput)
@@ -118,6 +120,8 @@ abstract class LegacyReobfuscateJar extends ToolExec {
118120
protected static abstract class Action implements WorkAction<Parameters> {
119121
@CompileStatic
120122
static interface Parameters extends WorkParameters {
123+
Property<LogLevel> getLogLevel()
124+
121125
RegularFileProperty getSrg()
122126
RegularFileProperty getOutput()
123127
RegularFileProperty getTemporaryOutput()
@@ -132,7 +136,7 @@ abstract class LegacyReobfuscateJar extends ToolExec {
132136
@Override
133137
void execute() {
134138
var packages = new HashSet<String>()
135-
var srgMappings = IMappingFile.load(this.parameters.srg.asFile.get())
139+
var srgMappings = IMappingFile.load(parameters.srg.asFile.get())
136140
for (IMappingFile.IClass srgClass : srgMappings.getClasses()) {
137141
String named = srgClass.getOriginal()
138142
int idx = named.lastIndexOf('/')
@@ -141,17 +145,17 @@ abstract class LegacyReobfuscateJar extends ToolExec {
141145
}
142146
}
143147

144-
var temporaryOutput = this.parameters.temporaryOutput.asFile.get()
148+
var temporaryOutput = parameters.temporaryOutput.asFile.get()
145149
try (ZipFile zin = new ZipFile(temporaryOutput)
146-
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(this.parameters.output.asFile.get()))) {
150+
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(parameters.output.asFile.get()))) {
147151
for (Enumeration<? extends ZipEntry> enu = zin.entries(); enu.hasMoreElements(); ) {
148152
ZipEntry entry = enu.nextElement()
149153
boolean filter = entry.isDirectory() || entry.getName().startsWith("mcp/") //Directories and MCP's annotations
150-
if (!this.parameters.keepPackages.get()) filter |= packages.contains(entry.getName())
151-
if (!this.parameters.keepData.get()) filter |= !entry.getName().endsWith(".class")
154+
if (!parameters.keepPackages.get()) filter |= packages.contains(entry.getName())
155+
if (!parameters.keepData.get()) filter |= !entry.getName().endsWith(".class")
152156

153157
if (filter) {
154-
LOGGER.lifecycle("Filtered: {}", entry.getName())
158+
LOGGER.log(parameters.logLevel.get(), "Filtered: {}", entry.getName())
155159
continue
156160
}
157161
out.putNextEntry(entry)

0 commit comments

Comments
 (0)