From 92654376f8745d3bf0adbb6dc8db981337d85e1a Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 22 Jan 2025 18:40:10 +0000 Subject: [PATCH] Use correct sourceset --- .../fabricapi/FabricApiAbstractSourceSet.java | 14 ++++++++------ .../configuration/fabricapi/FabricApiTesting.java | 9 ++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/configuration/fabricapi/FabricApiAbstractSourceSet.java b/src/main/java/net/fabricmc/loom/configuration/fabricapi/FabricApiAbstractSourceSet.java index 6ffdce0c9..22bec5966 100644 --- a/src/main/java/net/fabricmc/loom/configuration/fabricapi/FabricApiAbstractSourceSet.java +++ b/src/main/java/net/fabricmc/loom/configuration/fabricapi/FabricApiAbstractSourceSet.java @@ -46,7 +46,7 @@ abstract class FabricApiAbstractSourceSet { protected abstract String getSourceSetName(); - protected void configureSourceSet(Property modId, boolean isClient) { + protected SourceSet configureSourceSet(Property modId, boolean isClient) { final LoomGradleExtension extension = LoomGradleExtension.get(getProject()); final SourceSet mainSourceSet = SourceSetHelper.getMainSourceSet(getProject()); @@ -54,18 +54,18 @@ protected void configureSourceSet(Property modId, boolean isClient) { SourceSetContainer sourceSets = SourceSetHelper.getSourceSets(getProject()); - // Create the new datagen sourceset, depend on the main or client sourceset. - SourceSet dataGenSourceSet = sourceSets.create(getSourceSetName(), sourceSet -> { - dependsOn(sourceSet, mainSourceSet); + // Create the new sourceset, depend on the main or client sourceset. + SourceSet sourceSet = sourceSets.create(getSourceSetName(), ss -> { + dependsOn(ss, mainSourceSet); if (isClientAndSplit) { - dependsOn(sourceSet, SourceSetHelper.getSourceSetByName(MinecraftSourceSets.Split.CLIENT_ONLY_SOURCE_SET_NAME, getProject())); + dependsOn(ss, SourceSetHelper.getSourceSetByName(MinecraftSourceSets.Split.CLIENT_ONLY_SOURCE_SET_NAME, getProject())); } }); modId.convention(getProject().provider(() -> { try { - final FabricModJson fabricModJson = FabricModJsonFactory.createFromSourceSetsNullable(getProject(), dataGenSourceSet); + final FabricModJson fabricModJson = FabricModJsonFactory.createFromSourceSetsNullable(getProject(), sourceSet); if (fabricModJson == null) { throw new RuntimeException("Could not find a fabric.mod.json file in the data source set or a value for DataGenerationSettings.getModId()"); @@ -83,6 +83,8 @@ protected void configureSourceSet(Property modId, boolean isClient) { }); extension.createRemapConfigurations(sourceSets.getByName(getSourceSetName())); + + return sourceSet; } private static void extendsFrom(Project project, String name, String extendsFrom) { diff --git a/src/main/java/net/fabricmc/loom/configuration/fabricapi/FabricApiTesting.java b/src/main/java/net/fabricmc/loom/configuration/fabricapi/FabricApiTesting.java index a5893e932..230840761 100644 --- a/src/main/java/net/fabricmc/loom/configuration/fabricapi/FabricApiTesting.java +++ b/src/main/java/net/fabricmc/loom/configuration/fabricapi/FabricApiTesting.java @@ -65,7 +65,6 @@ protected String getSourceSetName() { void configureTests(Action action) { final LoomGradleExtension extension = LoomGradleExtension.get(getProject()); final TaskContainer tasks = getProject().getTasks(); - final SourceSet mainSourceSet = SourceSetHelper.getMainSourceSet(getProject()); GameTestSettings settings = getProject().getObjects().newInstance(GameTestSettings.class); settings.getCreateSourceSet().convention(false); @@ -77,8 +76,12 @@ void configureTests(Action action) { action.execute(settings); + final SourceSet testSourceSet; + if (settings.getCreateSourceSet().get()) { - configureSourceSet(settings.getModId(), true); + testSourceSet = configureSourceSet(settings.getModId(), true); + } else { + testSourceSet = SourceSetHelper.getMainSourceSet(getProject()); } Consumer configureBase = run -> { @@ -100,7 +103,7 @@ void configureTests(Action action) { if (settings.getEnableClientGameTests().get()) { // Not ideal as there may be multiple resources directories, if this isnt correct the mod will need to override this. - final File resourcesDir = mainSourceSet.getResources().getFiles().stream().findAny().orElse(null); + final File resourcesDir = testSourceSet.getResources().getFiles().stream().findAny().orElse(null); RunConfigSettings clientGameTest = extension.getRunConfigs().create("clientGameTest", run -> { run.inherit(extension.getRunConfigs().getByName("client"));