Skip to content

Commit

Permalink
Fix dyn projects config use.
Browse files Browse the repository at this point in the history
Add test to round trip the installer.
  • Loading branch information
marchermans committed Nov 4, 2024
1 parent 5f2993b commit 8e3b851
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class InstallerProfileTests extends BuilderBasedTestSpecification {
private PublishingProjectSetup createPublishingProject(String projectId, String patchedBuildConfiguration) {
def rootProject = create(projectId, {
it.property(CachedExecutionService.DEBUG_CACHE_PROPERTY, 'true')
it.property("neogradle.runtime.platform.installer.debug", "true")
it.settingsPlugin(pluginUnderTest)
it.settings("""
dynamicProjects {
Expand Down Expand Up @@ -64,6 +65,16 @@ class InstallerProfileTests extends BuilderBasedTestSpecification {
it.file("server_files/args.txt", """
Something to Inject into
""")
it.file("server_files/run.sh", """
#!/bin/bash
echo "Test server starter script"
""")
it.file("server_files/run.bat", """
echo "Test server starter script"
""")
it.file("server_files/user_jvm_args.txt", """
-Xmx2G
""")
//The following properties are needed as we do not have an abstract layer over the tokens needed.
it.property("fancy_mod_loader_version", "1.0.0")
it.enableGradleParallelRunning()
Expand Down Expand Up @@ -373,5 +384,36 @@ class InstallerProfileTests extends BuilderBasedTestSpecification {
jsonFile.text.contains("net.neoforged.installertools:binarypatcher:2.1.5:fatjar")
!jsonFile.text.contains("net.neoforged.installertools:binarypatcher:2.1.7:fatjar")
}

def "a published installer can be invoked to install a server"() {
given:
def project = createPublishingProject("published-userdev", """
tasks.register("installTestServer", JavaExec.class) {
classpath(tasks.named("signInstallerJar").flatMap { it.output })
args("--installServer", file("build/testserverinstall").absolutePath)
dependsOn("signInstallerJar")
}
""")

project.rootProject.run { it.tasks ':neoforge:setup' }
patch(project)
project.rootProject.run { it.tasks ':neoforge:unpackSourcePatches'}
project.rootProject.run { it.tasks ':neoforge:assemble' }

when:
def publishingRun = project.rootProject.run {
it.tasks ':neoforge:installTestServer'
}

then:
publishingRun.task(":neoforge:installTestServer").outcome == TaskOutcome.SUCCESS

and:
def testServerDir = project.patchedProject.file("build/testserverinstall")

then:
testServerDir.exists()
testServerDir.listFiles().size() > 0
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ public void runtime(final String neoFormVersion, Directory patches, Directory re
CommonRuntimeExtension.configureCommonRuntimeTaskParameters(task, runtimeDefinition, workingDirectory);
});

var projectVersion = project.getVersion().toString();
final TaskProvider<CreateLegacyInstaller> installerJar = project.getTasks().register("legacyInstallerJar", CreateLegacyInstaller.class, task -> {
task.getInstallerCore().set(downloadInstaller.flatMap(WithOutput::getOutput));
task.getInstallerJson().set(createLegacyInstallerJson.flatMap(WithOutput::getOutput));
Expand All @@ -589,8 +590,8 @@ public void runtime(final String neoFormVersion, Directory patches, Directory re

if (project.getProperties().containsKey("neogradle.runtime.platform.installer.debug") && Boolean.parseBoolean(project.getProperties().get("neogradle.runtime.platform.installer.debug").toString())) {
task.from(signUniversalJar.flatMap(WithOutput::getOutput), spec -> {
spec.into(String.format("/maven/net/neoforged/neoforge/%s/", project.getVersion()));
spec.rename(name -> String.format("neoforge-%s-universal.jar", project.getVersion()));
spec.into(String.format("/maven/net/neoforged/neoforge/%s/", projectVersion));
spec.rename(name -> String.format("neoforge-%s-universal.jar", projectVersion));
});
}
});
Expand Down

0 comments on commit 8e3b851

Please sign in to comment.