fabric-loom/src/main/java/net/fabricmc/loom/extension/MinecraftGradleExtension.java
modmuss50 08e548b6c6
Expose layered mappings as an API (#490)
* Expose layered mappings as an API

* Add FileSpec

* Cleanup and support DependencyFileSpec
2021-09-13 17:58:52 +01:00

153 lines
4.5 KiB
Java

/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2021 FabricMC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.fabricmc.loom.extension;
import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.publish.maven.MavenPublication;
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
import net.fabricmc.loom.api.MixinExtensionAPI;
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
import net.fabricmc.loom.api.mappings.layered.spec.LayeredMappingSpecBuilder;
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
import net.fabricmc.loom.configuration.processors.JarProcessor;
import net.fabricmc.loom.util.DeprecationHelper;
public class MinecraftGradleExtension implements LoomGradleExtensionAPI {
private final LoomGradleExtensionAPI parent;
private boolean deprecationReported = false;
public MinecraftGradleExtension(LoomGradleExtensionAPI parent) {
this.parent = parent;
}
private void reportDeprecation() {
if (!deprecationReported) {
getDeprecationHelper().replaceWithInLoom0_11("minecraft", "loom");
deprecationReported = true;
}
}
@Override
public DeprecationHelper getDeprecationHelper() {
return parent.getDeprecationHelper();
}
@Override
public RegularFileProperty getAccessWidenerPath() {
reportDeprecation();
return parent.getAccessWidenerPath();
}
@Override
public Property<Boolean> getShareRemapCaches() {
reportDeprecation();
return parent.getShareRemapCaches();
}
@Override
public ListProperty<LoomDecompiler> getGameDecompilers() {
reportDeprecation();
return parent.getGameDecompilers();
}
@Override
public ListProperty<JarProcessor> getGameJarProcessors() {
reportDeprecation();
return parent.getGameJarProcessors();
}
@Override
public ConfigurableFileCollection getLog4jConfigs() {
reportDeprecation();
return parent.getLog4jConfigs();
}
@Override
public Dependency layered(Action<LayeredMappingSpecBuilder> action) {
reportDeprecation();
return parent.layered(action);
}
@Override
public Property<Boolean> getRemapArchives() {
reportDeprecation();
return parent.getRemapArchives();
}
@Override
public void runs(Action<NamedDomainObjectContainer<RunConfigSettings>> action) {
reportDeprecation();
parent.runs(action);
}
@Override
public NamedDomainObjectContainer<RunConfigSettings> getRunConfigs() {
reportDeprecation();
return parent.getRunConfigs();
}
@Override
public void mixin(Action<MixinExtensionAPI> action) {
reportDeprecation();
parent.mixin(action);
}
@Override
public MixinExtensionAPI getMixin() {
reportDeprecation();
return parent.getMixin();
}
@Override
public Property<String> getCustomMinecraftManifest() {
reportDeprecation();
return parent.getCustomMinecraftManifest();
}
@Override
public Property<Boolean> getSetupRemappedVariants() {
reportDeprecation();
return parent.getSetupRemappedVariants();
}
@Override
public void disableDeprecatedPomGeneration(MavenPublication publication) {
reportDeprecation();
parent.disableDeprecatedPomGeneration(publication);
}
@Override
public String getModVersion() {
reportDeprecation();
throw new UnsupportedOperationException("Use loom extension");
}
}