Leave RCS.data() intact, only apply hardcoded game args if old api is used

This commit is contained in:
Juuz
2023-02-18 19:28:26 +02:00
parent 6ac4b6da9e
commit 0e3d0c3868
3 changed files with 18 additions and 23 deletions

View File

@@ -110,7 +110,7 @@ public interface ForgeExtensionAPI {
* {@link #dataGen(Action)}.
*
* @return the list
* @deprecated See {@link net.fabricmc.loom.configuration.ide.RunConfigSettings#data}.
* @deprecated Removed in favor of configuring the data generator directly.
*/
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")
@Deprecated(forRemoval = true)
@@ -120,7 +120,7 @@ public interface ForgeExtensionAPI {
* Applies data generation settings.
*
* @param action the action to configure data generation
* @deprecated See {@link net.fabricmc.loom.configuration.ide.RunConfigSettings#data}.
* @deprecated Removed in favor of configuring the data generator directly.
*/
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")
@Deprecated(forRemoval = true)
@@ -128,7 +128,7 @@ public interface ForgeExtensionAPI {
/**
* Data generation config.
* @deprecated See {@link net.fabricmc.loom.configuration.ide.RunConfigSettings#data}.
* @deprecated Removed in favor of configuring the data generator directly.
*/
@ApiStatus.NonExtendable
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")

View File

@@ -328,23 +328,12 @@ public final class RunConfigSettings implements Named {
/**
* Configure run config with the default data options.
*
* @deprecated Use <code>{@link #environment}("server")</code> and <code>{@link #forgeTemplate}("data")</code> instead and
* configure the data generator manually. Deprecated for removal for two reasons:
* <ol>
* <li>This method is only needed on Forge. Fabric setups should use {@link #server}.
* <li>It's inflexible and hardcodes the output path as well as validation.
* </ol>
* <p>This method can only be used on Forge.
*/
@ApiStatus.ScheduledForRemoval(inVersion = "2.0")
@Deprecated(forRemoval = true)
public void data() {
extension.getDeprecationHelper().warn("RunConfigSettings.data() has been deprecated and replaced with forgeTemplate(\"data\"). This will be removed in Loom 2.0.");
ModPlatform.assertPlatform(getExtension(), ModPlatform.FORGE, () -> "RunConfigSettings.data() is only usable on Forge.");
environment("data");
defaultMainClass(Constants.Knot.KNOT_SERVER);
if (getExtension().isForge()) {
forgeTemplate("data");
}
forgeTemplate("data");
}
/**

View File

@@ -112,14 +112,20 @@ public abstract class GenerateDLIConfigTask extends AbstractLoomTask {
.property("fabric.yarnWithSrg.path", getExtension().getMappingConfiguration().tinyMappingsWithSrg.toAbsolutePath().toString())
.property("unprotect.mappings", unprotectMappings)
.argument("data", "--all")
.argument("data", "--mod")
.argument("data", String.join(",", getExtension().getForge().getDataGenMods()))
.argument("data", "--output")
.argument("data", getProject().file("src/generated/resources").getAbsolutePath())
.property("mixin.env.remapRefMap", "true");
final List<String> dataGenMods = getExtension().getForge().getDataGenMods();
// Only apply the hardcoded data arguments if the deprecated data generator API is being used.
if (!dataGenMods.isEmpty()) {
launchConfig
.argument("data", "--all")
.argument("data", "--mod")
.argument("data", String.join(",", getExtension().getForge().getDataGenMods()))
.argument("data", "--output")
.argument("data", getProject().file("src/generated/resources").getAbsolutePath());
}
if (PropertyUtil.getAndFinalize(getExtension().getForge().getUseCustomMixin())) {
launchConfig.property("mixin.forgeloom.inject.mappings.srg-named", getExtension().getMappingConfiguration().getReplacedTarget(getExtension(), "srg").toAbsolutePath().toString());
} else {