Skip to content

Commit

Permalink
[Fix]: Update DiffPatch and introduce testing (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans authored Jun 26, 2024
1 parent 804864d commit 2a8a833
Show file tree
Hide file tree
Showing 18 changed files with 659 additions and 29 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ subprojects.forEach { Project subProject ->
}
}

subProject.tasks.withType(ProcessResources).configureEach {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

//Wire up our custom repositories.
subProject.repositories.mavenLocal()
subProject.repositories.maven { MavenArtifactRepository repository ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public IdeManagementExtension(Project project) {
* @return whether this is an IntelliJ-based invocation
*/
public boolean isIdeaImport() {
return Boolean.getBoolean("idea.active");
return Boolean.getBoolean("idea.sync.active");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ private void configureParchmentDefaults() {
return DEFAULT_PARCHMENT_GROUP
+ ":" + DEFAULT_PARCHMENT_ARTIFACT_PREFIX + minecraftVersion
+ ":" + mappingVersion
// We need the checked variant for now since it resolves
// parameters conflicting with local variables by prefixing everything with "p"
+ ":checked"
+ "@zip";
})
)
);
parchment.getConflictPrefix().convention("p_");
parchment.getMinecraftVersion().convention(
getStringProperty("parchment.minecraftVersion")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ interface Parchment extends ConfigurableDSLElement<Parchment> {
@DSLProperty
Property<String> getParchmentArtifact();

/**
* The prefix added to parameters in parchment when a conflict arises.
*/
@Input
@DSLProperty
Property<String> getConflictPrefix();

/**
* Minecraft version of parchment to use. This property is
* ignored if {@link #getParchmentArtifact()} is set explicitly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Constants {
public static final String DEFAULT_PARCHMENT_GROUP = "org.parchmentmc.data"
public static final String DEFAULT_PARCHMENT_ARTIFACT_PREFIX = "parchment-"
public static final String DEFAULT_PARCHMENT_MAVEN_URL = "https://maven.parchmentmc.org/"
public static final String JST_TOOL_ARTIFACT = "net.neoforged.jst:jst-cli-bundle:1.0.39"
public static final String JST_TOOL_ARTIFACT = "net.neoforged.jst:jst-cli-bundle:1.0.43"
public static final String DEVLOGIN_TOOL_ARTIFACT = "net.covers1624:DevLogin:0.1.0.4"
public static final String DEVLOGIN_MAIN_CLASS = "net.covers1624.devlogin.DevLogin"

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ spock_version=2.1
spock_groovy_version=3.0
mockito_version=4.11.0
jimfs_version=1.2
trainingwheels_version=1.0.48
trainingwheels_version=1.0.49
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ protected void bakeDefinition(NeoFormRuntimeDefinition definition) {
remapTask.configure(task -> configureMcpRuntimeTaskWithDefaults(spec, neoFormDirectory, symbolicDataSources, task));

TaskProvider<? extends WithOutput> recompileInput = maybeApplyParchment(
spec,
definition,
remapTask,
symbolicDataSources,
neoFormDirectory,
Expand Down Expand Up @@ -492,21 +492,22 @@ protected void bakeDefinition(NeoFormRuntimeDefinition definition) {
});
}

private static TaskProvider<? extends WithOutput> maybeApplyParchment(NeoFormRuntimeSpecification spec,
private static TaskProvider<? extends WithOutput> maybeApplyParchment(NeoFormRuntimeDefinition runtimeDefinition,
TaskProvider<? extends WithOutput> recompileInput,
Map<String, String> symbolicDataSources,
File neoFormDirectory,
Provider<RegularFile> listLibrariesOutput) {
Project project = spec.getProject();
Project project = runtimeDefinition.getSpecification().getProject();
Parchment parchment = project.getExtensions().getByType(Subsystems.class).getParchment();
Tools tools = project.getExtensions().getByType(Subsystems.class).getTools();
if (!parchment.getEnabled().get()) {
return recompileInput;
}

TaskProvider<? extends Runtime> applyParchmentTask = project.getTasks().register(CommonRuntimeUtils.buildTaskName(spec, "applyParchment"), DefaultExecute.class, task -> {
TaskProvider<? extends Runtime> applyParchmentTask = project.getTasks().register(CommonRuntimeUtils.buildTaskName(runtimeDefinition, "applyParchment"), DefaultExecute.class, task -> {
// Provide the mappings via artifact
File mappingFile = ToolUtilities.resolveTool(project, parchment.getParchmentArtifact().get());
String conflictPrefix = parchment.getConflictPrefix().get();
File toolExecutable = ToolUtilities.resolveTool(project, tools.getJST().get());

task.getArguments().putFile("mappings", project.provider(() -> mappingFile));
Expand All @@ -521,13 +522,23 @@ private static TaskProvider<? extends WithOutput> maybeApplyParchment(NeoFormRun
task.getProgramArguments().add("{mappings}");
task.getProgramArguments().add("--in-format=archive");
task.getProgramArguments().add("--out-format=archive");
task.getProgramArguments().add("--parchment-conflict-prefix=%s".formatted(conflictPrefix));
task.getProgramArguments().add("{input}");
task.getProgramArguments().add("{output}");

final StringBuilder builder = new StringBuilder();
runtimeDefinition.getAllDependencies().forEach(f -> {
if (!builder.isEmpty()) {
builder.append(File.pathSeparator);
}
builder.append(f.getAbsolutePath());
});
task.getProgramArguments().add("--classpath=" + builder);

task.dependsOn(listLibrariesOutput);
task.dependsOn(recompileInput);

configureCommonRuntimeTaskParameters(task, symbolicDataSources, "applyParchment", spec, neoFormDirectory);
configureCommonRuntimeTaskParameters(task, symbolicDataSources, "applyParchment", runtimeDefinition.getSpecification(), neoFormDirectory);
});

return applyParchmentTask;
Expand Down
1 change: 1 addition & 0 deletions platform/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id 'groovy'
id 'java-gradle-plugin'
}

Expand Down
Loading

0 comments on commit 2a8a833

Please sign in to comment.