Skip to content

Commit

Permalink
Add support for testing the platform
Browse files Browse the repository at this point in the history
Fix issues with patch baking due to bugs in DP2
Add roundtrip testing for platform module
  • Loading branch information
marchermans committed Jun 25, 2024
1 parent 4c76373 commit 6b35f9c
Show file tree
Hide file tree
Showing 12 changed files with 624 additions and 11 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
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ maven_artifact_version=3.8.5
ivy_artifact_version=2.5.1
httpclient_version=4.5.13
srgutils_version=0.4.13
diffpatch_version=2.0.0.34
diffpatch_version=2.0.0.35
jarjar_version=0.4.1
jetbrains_annotations_version=23.0.0
gradle_idea_extension_version=1.1.6
Expand All @@ -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
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

Large diffs are not rendered by default.

Binary file added platform/src/functionalTest/resources/icon.ico
Binary file not shown.
Binary file added platform/src/functionalTest/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void neoform(final String neoFormVersion) {

final NeoFormRuntimeExtension neoFormRuntimeExtension = project.getExtensions().getByType(NeoFormRuntimeExtension.class);
final NeoFormRuntimeDefinition runtimeDefinition = neoFormRuntimeExtension.create(builder -> {
builder.withNeoFormVersion(neoFormVersion).withDistributionType(DistributionType.CLIENT);
builder.withNeoFormVersion(neoFormVersion).withDistributionType(DistributionType.JOINED);

NeoFormRuntimeUtils.configureDefaultRuntimeSpecBuilder(project, builder);
});
Expand Down Expand Up @@ -439,7 +439,8 @@ public void runtime(final String neoFormVersion, Directory patches, Directory re
});

profile.getLibraries().add(Library.fromOutput(signUniversalJar, project, "net.neoforged", "neoforge", project.getVersion().toString(), "universal"));


//TODO: Abstract this away to some kind of DSL property
profile.getIcon().set(project.provider(() -> {
final File icon = new File(project.getRootProject().getProjectDir(), "docs/assets/neoforged.ico");
if (!icon.exists()) {
Expand Down Expand Up @@ -818,6 +819,8 @@ private void configureRunType(final Project project, final RunType runType, fina
}

private static void configureInstallerTokens(final TokenizedTask tokenizedTask, final RuntimeDevRuntimeDefinition runtimeDefinition, final Collection<Configuration> ignoreConfigurations, final Configuration pluginLayerLibraries, final Configuration gameLayerLibraries) {
//TODO: This should be moved to a DSL configurable model.

tokenizedTask.token("TASK", "forgeserver");
tokenizedTask.token("MAVEN_PATH", String.format("%s/%s/%s", tokenizedTask.getProject().getGroup().toString().replace('.', '/'), tokenizedTask.getProject().getName(), tokenizedTask.getProject().getVersion()));
tokenizedTask.token("FORGE_VERSION", tokenizedTask.getProject().getVersion());
Expand Down Expand Up @@ -928,7 +931,7 @@ private void configureUserdevRunType(final RunType runType, Configuration module
}

private static String createCoordinate(final Project project, final String classifier) {
return Artifact.from(project, classifier, "jar").toString();
return Objects.toString(Artifact.from(project, classifier, "jar"));
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,19 @@ public String getMinecraftVersion() {
}

public Directory getPatchesDirectory() {
if (!patchesDirectory.getAsFile().exists()) {
//Ensure the directory exists
patchesDirectory.getAsFile().mkdirs();
}

return patchesDirectory;
}

public Directory getRejectsDirectory() {
if (!rejectsDirectory.getAsFile().exists()) {
//Ensure the directory exists
rejectsDirectory.getAsFile().mkdirs();
}
return rejectsDirectory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void doTask() throws Exception {
Path base = getBase().get().getAsFile().toPath();
Path modified = getModified().get().getAsFile().toPath();
Path output = getOutput().get().getAsFile().toPath();
getProject().getLogger().info("Base: {}", base);
getProject().getLogger().info("Modified: {}", modified);
getLogger().info("Base: {}", base);
getLogger().info("Modified: {}", modified);

DiffOperation.Builder builder = DiffOperation.builder()
.logTo(getLogger()::lifecycle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import java.util.Set;
import java.util.stream.Collectors;

//TODO: This task crashes a run when the input template file is not present.
@CacheableTask
public abstract class CreateClasspathFiles extends DefaultRuntime implements TokenizedTask {



public CreateClasspathFiles() {
getTemplate().set(getProject().getRootProject().file("server_files/args.txt"));
getOutputFileName().convention("args.txt");
Expand Down Expand Up @@ -71,7 +71,7 @@ public void doTask() throws Exception {
copySpec.into(getOutputDirectory().get().getAsFile());
});
}

@InputFile
@PathSensitive(PathSensitivity.NONE)
public abstract RegularFileProperty getTemplate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public CreateLegacyInstaller() {
spec.into("data");
spec.rename(name -> "server.lzma");
});


//TODO: Handle this better. They are hardcoded and if they don't exists it will fail.
getUrlIcon().fileValue(getProject().getRootProject().file("src/main/resources/url.png"));
getInstallerLogo().fileValue(getProject().getRootProject().file("src/main/resources/neoforged_logo.png"));
from(getData(), spec -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ package net.neoforged.gradle.utils.test.extensions

import groovy.transform.CompileStatic

import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream

/**
* Extensions for the [File] class.
*/
Expand All @@ -13,4 +18,22 @@ class FileExtensions {
static String getPropertiesPath(final File self) {
return self.absolutePath.replace("\\", "\\\\")
}

static File getZipEntry(final File self, final String path) {
final ZipFile zipFile = new ZipFile(self)
final ZipEntry entry = zipFile.getEntry(path)
if (entry == null) {
throw new IllegalArgumentException("Entry not found: $path")
}

final File tempFile = File.createTempFile("zipEntry", ".tmp")
final InputStream zipInputStream = zipFile.getInputStream(entry)
final OutputStream tempOutputStream = new FileOutputStream(tempFile)
tempOutputStream << zipInputStream
tempOutputStream.close()
zipInputStream.close()
zipFile.close()

return tempFile;
}
}

0 comments on commit 6b35f9c

Please sign in to comment.