Skip to content

Commit

Permalink
Fix crash in DownloadAssetsTask when there is no client run config. (#…
Browse files Browse the repository at this point in the history
…1137)

* Fix crash in DownloadAssetsTask when there is no client run config.

* Fix build
  • Loading branch information
modmuss50 authored Jul 4, 2024
1 parent ed1138c commit 6c64caa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/net/fabricmc/loom/task/DownloadAssetsTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Objects;

import javax.inject.Inject;

Expand Down Expand Up @@ -92,8 +91,9 @@ public DownloadAssetsTask() {
getLegacyResourcesDirectory().set(new File(assetsDir, "/legacy/" + versionInfo.id()));
} else {
// pre-1.6 resources
RunConfigSettings client = Objects.requireNonNull(getExtension().getRunConfigs().findByName("client"), "Could not find client run config");
getLegacyResourcesDirectory().set(new File(getProject().getProjectDir(), client.getRunDir() + "/resources"));
RunConfigSettings client = getExtension().getRunConfigs().findByName("client");
String runDir = client != null ? client.getRunDir() : "run";
getLegacyResourcesDirectory().set(new File(getProject().getProjectDir(), runDir + "/resources"));
}

getResourcesBaseUrl().set(MirrorUtil.getResourcesBase(getProject()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,32 @@ class RunConfigTest extends Specification implements GradleProjectTestTrait {
where:
version << STANDARD_TEST_VERSIONS
}
// Test that the download assets task doesnt depend on a client run existing.
@Unroll
def "cleared runs (gradle #version)"() {
setup:
def gradle = gradleProject(project: "minimalBase", version: version)
gradle.buildGradle << '''
dependencies {
minecraft "com.mojang:minecraft:1.18.1"
mappings "net.fabricmc:yarn:1.18.1+build.18:v2"
modImplementation "net.fabricmc:fabric-loader:0.12.12"
}
loom {
runs.clear()
}
'''
when:
def result = gradle.run(tasks: ["downloadAssets"])
then:
result.task(":downloadAssets").outcome == SUCCESS
where:
version << STANDARD_TEST_VERSIONS
}
}

0 comments on commit 6c64caa

Please sign in to comment.