-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0a30b7
commit 515106f
Showing
7 changed files
with
306 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 148 additions & 22 deletions
170
platform/src/main/java/net/neoforged/gradle/platform/extensions/DynamicProjectExtension.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...orm/src/main/java/net/neoforged/gradle/platform/tasks/OfficialMappingsJustParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package net.neoforged.gradle.platform.tasks; | ||
|
||
import net.minecraftforge.srgutils.IMappingBuilder; | ||
import net.minecraftforge.srgutils.IMappingFile; | ||
import net.neoforged.gradle.common.runtime.tasks.DefaultRuntime; | ||
import net.neoforged.gradle.dsl.common.tasks.WithOutput; | ||
import org.gradle.api.file.RegularFileProperty; | ||
import org.gradle.api.tasks.CacheableTask; | ||
import org.gradle.api.tasks.InputFile; | ||
import org.gradle.api.tasks.PathSensitive; | ||
import org.gradle.api.tasks.PathSensitivity; | ||
import org.gradle.api.tasks.TaskAction; | ||
|
||
import javax.inject.Inject; | ||
import java.io.IOException; | ||
|
||
@CacheableTask | ||
public abstract class OfficialMappingsJustParameters extends DefaultRuntime implements WithOutput { | ||
@Inject | ||
public OfficialMappingsJustParameters() { | ||
getOutputFileName().set("output.tsrg"); | ||
} | ||
|
||
@InputFile | ||
@PathSensitive(PathSensitivity.NONE) | ||
public abstract RegularFileProperty getInput(); | ||
|
||
@TaskAction | ||
void exec() throws IOException { | ||
var source = IMappingFile.load(getInput().getAsFile().get()); | ||
var builder = IMappingBuilder.create(); | ||
source.getClasses().forEach(cls -> { | ||
var c = builder.addClass(cls.getMapped(), cls.getMapped()); | ||
cls.getMethods().forEach(mtd -> { | ||
if (mtd.getParameters().isEmpty()) return; | ||
|
||
var m = c.method(mtd.getMappedDescriptor(), mtd.getMapped(), mtd.getMapped()); | ||
mtd.getParameters().forEach(par -> m.parameter(par.getIndex(), par.getOriginal(), par.getMapped())); | ||
}); | ||
}); | ||
builder.build().write(getOutput().get().getAsFile().toPath(), IMappingFile.Format.TSRG2); | ||
} | ||
} |