Replace getRemapArchives & getSetupRemappedVariants with a gradle property. (#678)

* Replace getRemapArchives & getSetupRemappedVariants with a gradle property as they are evaluated too early to be set.

* Use true for all projects.

* Cleanup, you can set properties for each subproject.

* Fix docs.
This commit is contained in:
modmuss50
2022-07-01 18:13:56 +01:00
committed by GitHub
parent 9b2b857b38
commit 97927f913a
3 changed files with 24 additions and 11 deletions

View File

@@ -74,6 +74,10 @@ public interface LoomGradleExtensionAPI {
Dependency layered(Action<LayeredMappingSpecBuilder> action);
/**
* @deprecated Broken due to be evaluated too early. Replaced with "fabric.loom.dontRemap" gradle property.
*/
@Deprecated(forRemoval = true)
Property<Boolean> getRemapArchives();
void runs(Action<NamedDomainObjectContainer<RunConfigSettings>> action);
@@ -105,13 +109,9 @@ public interface LoomGradleExtensionAPI {
Property<String> getCustomMinecraftManifest();
/**
* If true, Loom will replace the {@code -dev} jars in the {@code *Elements} configurations
* with remapped outgoing variants.
*
* <p>Will only apply if {@link #getRemapArchives()} is also true.
*
* @return the property controlling the setup of remapped variants
* @deprecated Broken due to be evaluated too early. Replaced with "fabric.loom.disableRemappedVariants" gradle property.
*/
@Deprecated(forRemoval = true)
Property<Boolean> getSetupRemappedVariants();
/**

View File

@@ -155,8 +155,6 @@ public final class CompileConfiguration {
extension.setDependencyManager(dependencyManager);
dependencyManager.handleDependencies(project);
extension.getRemapArchives().finalizeValue();
MixinExtension mixin = LoomGradleExtension.get(project).getMixin();
if (mixin.getUseLegacyMixinAp().get()) {

View File

@@ -49,7 +49,7 @@ public class RemapTaskConfiguration {
final TaskContainer tasks = project.getTasks();
final LoomGradleExtension extension = LoomGradleExtension.get(project);
if (!extension.getRemapArchives().get()) {
if (getBooleanProperty(project, "fabric.loom.dontRemap")) {
extension.getUnmappedModCollection().from(project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME));
return;
}
@@ -81,7 +81,7 @@ public class RemapTaskConfiguration {
trySetupSourceRemapping(project);
if (!extension.getSetupRemappedVariants().get()) {
if (getBooleanProperty(project, "fabric.loom.disableRemappedVariants")) {
return;
}
@@ -132,7 +132,7 @@ public class RemapTaskConfiguration {
tasks.named(BasePlugin.ASSEMBLE_TASK_NAME).configure(task -> task.dependsOn(remapSourcesTask));
if (!extension.getSetupRemappedVariants().get()) {
if (getBooleanProperty(project, "fabric.loom.disableRemappedVariants")) {
return;
}
@@ -155,4 +155,19 @@ public class RemapTaskConfiguration {
}
});
}
private static boolean getBooleanProperty(Project project, String key) {
boolean result = false;
Object value = project.getProperties().get(key);
if (value instanceof String) {
try {
result = Boolean.parseBoolean((String) value);
} catch (IllegalArgumentException ignored) {
// False
}
}
return result;
}
}