Refactor LoomGradleExtension (#431)
* First pass at refactoring the extension * Fix inital issues. * Combine some interfaces * Checkstyle * Fix years * Add isShareCaches to apidev/0.11
parent
2259a4efc8
commit
e439a1b354
|
@ -25,368 +25,86 @@
|
||||||
package net.fabricmc.loom;
|
package net.fabricmc.loom;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.cadixdev.lorenz.MappingSet;
|
import org.cadixdev.lorenz.MappingSet;
|
||||||
import org.cadixdev.mercury.Mercury;
|
import org.cadixdev.mercury.Mercury;
|
||||||
import org.gradle.api.Action;
|
import org.gradle.api.NamedDomainObjectProvider;
|
||||||
import org.gradle.api.NamedDomainObjectContainer;
|
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.artifacts.Dependency;
|
import org.gradle.api.artifacts.Configuration;
|
||||||
import org.gradle.api.file.ConfigurableFileCollection;
|
import org.gradle.api.file.ConfigurableFileCollection;
|
||||||
import org.gradle.api.plugins.BasePluginConvention;
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
|
|
||||||
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
|
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
|
||||||
import net.fabricmc.loom.configuration.InstallerData;
|
import net.fabricmc.loom.configuration.InstallerData;
|
||||||
import net.fabricmc.loom.configuration.LoomDependencyManager;
|
import net.fabricmc.loom.configuration.LoomDependencyManager;
|
||||||
import net.fabricmc.loom.configuration.LoomProjectData;
|
|
||||||
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
|
||||||
import net.fabricmc.loom.configuration.processors.JarProcessor;
|
|
||||||
import net.fabricmc.loom.configuration.processors.JarProcessorManager;
|
import net.fabricmc.loom.configuration.processors.JarProcessorManager;
|
||||||
import net.fabricmc.loom.configuration.providers.MinecraftProviderImpl;
|
import net.fabricmc.loom.configuration.providers.MinecraftProviderImpl;
|
||||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMappedProvider;
|
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.GradleMappingContext;
|
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec;
|
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilder;
|
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingsDependency;
|
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
||||||
|
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMappedProvider;
|
||||||
|
import net.fabricmc.loom.extension.LoomFiles;
|
||||||
|
import net.fabricmc.loom.extension.LoomGradleExtensionImpl;
|
||||||
|
|
||||||
public class LoomGradleExtension {
|
public interface LoomGradleExtension extends LoomGradleExtensionAPI {
|
||||||
public String refmapName;
|
static LoomGradleExtension get(Project project) {
|
||||||
public String loaderLaunchMethod;
|
return project.getExtensions().getByType(LoomGradleExtensionImpl.class);
|
||||||
public boolean remapMod = true;
|
|
||||||
public String customManifest = null;
|
|
||||||
public File accessWidener = null;
|
|
||||||
public Function<String, Object> intermediaryUrl = mcVer -> "https://maven.fabricmc.net/net/fabricmc/intermediary/" + mcVer + "/intermediary-" + mcVer + "-v2.jar";
|
|
||||||
public boolean shareCaches = false;
|
|
||||||
|
|
||||||
private final ConfigurableFileCollection unmappedMods;
|
|
||||||
private final ConfigurableFileCollection log4jConfigs;
|
|
||||||
|
|
||||||
final List<LoomDecompiler> decompilers = new ArrayList<>();
|
|
||||||
private final List<JarProcessor> jarProcessors = new ArrayList<>();
|
|
||||||
|
|
||||||
// Not to be set in the build.gradle
|
|
||||||
private final Project project;
|
|
||||||
private LoomDependencyManager dependencyManager;
|
|
||||||
private JarProcessorManager jarProcessorManager;
|
|
||||||
private InstallerData installerData;
|
|
||||||
private MappingSet[] srcMappingCache = new MappingSet[2];
|
|
||||||
private Mercury[] srcMercuryCache = new Mercury[2];
|
|
||||||
private Set<File> mixinMappings = Collections.synchronizedSet(new HashSet<>());
|
|
||||||
|
|
||||||
@ApiStatus.Internal
|
|
||||||
private final LoomProjectData projectData;
|
|
||||||
|
|
||||||
private NamedDomainObjectContainer<RunConfigSettings> runConfigs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loom will generate a new genSources task (with a new name, based off of {@link LoomDecompiler#name()})
|
|
||||||
* that uses the specified decompiler instead.
|
|
||||||
*/
|
|
||||||
public void addDecompiler(LoomDecompiler decompiler) {
|
|
||||||
decompilers.add(decompiler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
LoomFiles getFiles();
|
||||||
* Add a transformation over the mapped mc jar.
|
|
||||||
* Adding any jar processor will cause mapped mc jars to be stored per-project so that
|
|
||||||
* different transformation can be applied in different projects.
|
|
||||||
* This means remapping will need to be done individually per-project, which is slower when developing
|
|
||||||
* more than one project using the same minecraft version.
|
|
||||||
*/
|
|
||||||
public void addJarProcessor(JarProcessor processor) {
|
|
||||||
jarProcessors.add(processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MappingSet getOrCreateSrcMappingCache(int id, Supplier<MappingSet> factory) {
|
NamedDomainObjectProvider<Configuration> createLazyConfiguration(String name);
|
||||||
return srcMappingCache[id] != null ? srcMappingCache[id] : (srcMappingCache[id] = factory.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Mercury getOrCreateSrcMercuryCache(int id, Supplier<Mercury> factory) {
|
NamedDomainObjectProvider<Configuration> getLazyConfigurationProvider(String name);
|
||||||
return srcMercuryCache[id] != null ? srcMercuryCache[id] : (srcMercuryCache[id] = factory.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dependency officialMojangMappings() {
|
MappingSet getOrCreateSrcMappingCache(int id, Supplier<MappingSet> factory);
|
||||||
return layered(LayeredMappingSpecBuilder::officialMojangMappings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dependency layered(Action<LayeredMappingSpecBuilder> action) {
|
Mercury getOrCreateSrcMercuryCache(int id, Supplier<Mercury> factory);
|
||||||
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder();
|
|
||||||
action.execute(builder);
|
|
||||||
LayeredMappingSpec builtSpec = builder.build();
|
|
||||||
return new LayeredMappingsDependency(new GradleMappingContext(project, "layers_" + builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoomGradleExtension(Project project) {
|
ConfigurableFileCollection getUnmappedModCollection();
|
||||||
this.project = project;
|
|
||||||
this.unmappedMods = project.files();
|
|
||||||
this.runConfigs = project.container(RunConfigSettings.class,
|
|
||||||
baseName -> new RunConfigSettings(project, baseName));
|
|
||||||
this.log4jConfigs = project.files(getDefaultLog4jConfigFile());
|
|
||||||
projectData = new LoomProjectData(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
void setInstallerData(InstallerData data);
|
||||||
* @see ConfigurableFileCollection#from(Object...)
|
|
||||||
* @deprecated use {@link #getUnmappedModCollection()}{@code .from()} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void addUnmappedMod(Path file) {
|
|
||||||
getUnmappedModCollection().from(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
InstallerData getInstallerData();
|
||||||
* @deprecated use {@link #getUnmappedModCollection()} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public List<Path> getUnmappedMods() {
|
|
||||||
return unmappedMods.getFiles().stream()
|
|
||||||
.map(File::toPath)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigurableFileCollection getUnmappedModCollection() {
|
void setDependencyManager(LoomDependencyManager dependencyManager);
|
||||||
return unmappedMods;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstallerData(InstallerData data) {
|
LoomDependencyManager getDependencyManager();
|
||||||
this.installerData = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InstallerData getInstallerData() {
|
void setJarProcessorManager(JarProcessorManager jarProcessorManager);
|
||||||
return installerData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void accessWidener(Object file) {
|
JarProcessorManager getJarProcessorManager();
|
||||||
this.accessWidener = project.file(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getUserCache() {
|
default MinecraftProviderImpl getMinecraftProvider() {
|
||||||
File userCache = new File(project.getGradle().getGradleUserHomeDir(), "caches" + File.separator + "fabric-loom");
|
|
||||||
|
|
||||||
if (!userCache.exists()) {
|
|
||||||
userCache.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
return userCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getRootProjectPersistentCache() {
|
|
||||||
File projectCache = new File(project.getRootProject().file(".gradle"), "loom-cache");
|
|
||||||
|
|
||||||
if (!projectCache.exists()) {
|
|
||||||
projectCache.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
return projectCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getProjectPersistentCache() {
|
|
||||||
File projectCache = new File(project.file(".gradle"), "loom-cache");
|
|
||||||
|
|
||||||
if (!projectCache.exists()) {
|
|
||||||
projectCache.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
return projectCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getRootProjectBuildCache() {
|
|
||||||
File projectCache = new File(project.getRootProject().getBuildDir(), "loom-cache");
|
|
||||||
|
|
||||||
if (!projectCache.exists()) {
|
|
||||||
projectCache.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
return projectCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getProjectBuildCache() {
|
|
||||||
File projectCache = new File(project.getBuildDir(), "loom-cache");
|
|
||||||
|
|
||||||
if (!projectCache.exists()) {
|
|
||||||
projectCache.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
return projectCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getRemappedModCache() {
|
|
||||||
File remappedModCache = new File(getRootProjectPersistentCache(), "remapped_mods");
|
|
||||||
|
|
||||||
if (!remappedModCache.exists()) {
|
|
||||||
remappedModCache.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
return remappedModCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getNestedModCache() {
|
|
||||||
File nestedModCache = new File(getRootProjectPersistentCache(), "nested_mods");
|
|
||||||
|
|
||||||
if (!nestedModCache.exists()) {
|
|
||||||
nestedModCache.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
return nestedModCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getNativesJarStore() {
|
|
||||||
File natives = new File(getUserCache(), "natives/jars");
|
|
||||||
|
|
||||||
if (!natives.exists()) {
|
|
||||||
natives.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
return natives;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getNativesDirectory() {
|
|
||||||
if (project.hasProperty("fabric.loom.natives.dir")) {
|
|
||||||
return new File((String) project.property("fabric.loom.natives.dir"));
|
|
||||||
}
|
|
||||||
|
|
||||||
File natives = new File(getUserCache(), "natives/" + getMinecraftProvider().minecraftVersion());
|
|
||||||
|
|
||||||
if (!natives.exists()) {
|
|
||||||
natives.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
return natives;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasCustomNatives() {
|
|
||||||
return project.getProperties().get("fabric.loom.natives.dir") != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getDevLauncherConfig() {
|
|
||||||
return new File(getProjectPersistentCache(), "launch.cfg");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLoaderLaunchMethod() {
|
|
||||||
return loaderLaunchMethod != null ? loaderLaunchMethod : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoomDependencyManager getDependencyManager() {
|
|
||||||
return dependencyManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MinecraftProviderImpl getMinecraftProvider() {
|
|
||||||
return getDependencyManager().getProvider(MinecraftProviderImpl.class);
|
return getDependencyManager().getProvider(MinecraftProviderImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinecraftMappedProvider getMinecraftMappedProvider() {
|
default MappingsProviderImpl getMappingsProvider() {
|
||||||
return getMappingsProvider().mappedProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MappingsProviderImpl getMappingsProvider() {
|
|
||||||
return getDependencyManager().getProvider(MappingsProviderImpl.class);
|
return getDependencyManager().getProvider(MappingsProviderImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDependencyManager(LoomDependencyManager dependencyManager) {
|
default MinecraftMappedProvider getMinecraftMappedProvider() {
|
||||||
this.dependencyManager = dependencyManager;
|
return getMappingsProvider().mappedProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JarProcessorManager getJarProcessorManager() {
|
File getNextMixinMappings();
|
||||||
return jarProcessorManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJarProcessorManager(JarProcessorManager jarProcessorManager) {
|
Set<File> getAllMixinMappings();
|
||||||
this.jarProcessorManager = jarProcessorManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<JarProcessor> getJarProcessors() {
|
boolean isRootProject();
|
||||||
return jarProcessors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefmapName() {
|
boolean isShareCaches();
|
||||||
if (refmapName == null || refmapName.isEmpty()) {
|
|
||||||
String defaultRefmapName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-refmap.json";
|
|
||||||
project.getLogger().info("Could not find refmap definition, will be using default name: " + defaultRefmapName);
|
|
||||||
refmapName = defaultRefmapName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return refmapName;
|
default boolean ideSync() {
|
||||||
}
|
|
||||||
|
|
||||||
public boolean ideSync() {
|
|
||||||
return Boolean.parseBoolean(System.getProperty("idea.sync.active", "false"));
|
return Boolean.parseBoolean(System.getProperty("idea.sync.active", "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ideally this should use maven, but this is a lot easier
|
default String getCustomManifest() {
|
||||||
public Function<String, String> getIntermediaryUrl() {
|
// TODO reimplement
|
||||||
// Done like this to work around this possibly not being a java string...
|
return null;
|
||||||
return s -> intermediaryUrl.apply(s).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRootProject() {
|
default String getIntermediaryUrl(String minecraftVersion) {
|
||||||
return project.getRootProject() == project;
|
// TODO reimplement a way to change this, was never really supported api anyway
|
||||||
}
|
return String.format("https://maven.fabricmc.net/net/fabricmc/intermediary/%1$s/intermediary-%1$s-v2.jar", minecraftVersion);
|
||||||
|
|
||||||
public LoomGradleExtension getRootGradleExtension() {
|
|
||||||
if (isRootProject()) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
return project.getRootProject().getExtensions().getByType(LoomGradleExtension.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoomGradleExtension getSharedGradleExtension() {
|
|
||||||
return isShareCaches() ? getRootGradleExtension() : this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShareCaches() {
|
|
||||||
return shareCaches;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates a new file each time its called, this is then held onto later when remapping the output jar
|
|
||||||
// Required as now when using parallel builds the old single file could be written by another sourceset compile task
|
|
||||||
public synchronized File getNextMixinMappings() {
|
|
||||||
File mixinMapping = new File(getProjectBuildCache(), "mixin-map-" + getMinecraftProvider().minecraftVersion() + "-" + getMappingsProvider().mappingsVersion + "." + mixinMappings.size() + ".tiny");
|
|
||||||
mixinMappings.add(mixinMapping);
|
|
||||||
return mixinMapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<File> getAllMixinMappings() {
|
|
||||||
return Collections.unmodifiableSet(mixinMappings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<LoomDecompiler> getDecompilers() {
|
|
||||||
return decompilers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getDefaultLog4jConfigFile() {
|
|
||||||
return new File(getProjectPersistentCache(), "log4j.xml");
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getUnpickLoggingConfigFile() {
|
|
||||||
return new File(getProjectPersistentCache(), "unpick-logging.properties");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigurableFileCollection getLog4jConfigs() {
|
|
||||||
return log4jConfigs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runs(Action<NamedDomainObjectContainer<RunConfigSettings>> action) {
|
|
||||||
action.execute(runConfigs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NamedDomainObjectContainer<RunConfigSettings> getRunConfigs() {
|
|
||||||
return runConfigs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiStatus.Internal
|
|
||||||
public LoomProjectData getProjectData() {
|
|
||||||
return projectData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ import net.fabricmc.loom.configuration.MavenPublication;
|
||||||
import net.fabricmc.loom.configuration.ide.IdeConfiguration;
|
import net.fabricmc.loom.configuration.ide.IdeConfiguration;
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsCache;
|
import net.fabricmc.loom.configuration.providers.mappings.MappingsCache;
|
||||||
import net.fabricmc.loom.decompilers.DecompilerConfiguration;
|
import net.fabricmc.loom.decompilers.DecompilerConfiguration;
|
||||||
|
import net.fabricmc.loom.extension.LoomGradleExtensionImpl;
|
||||||
|
import net.fabricmc.loom.extension.LoomFilesImpl;
|
||||||
import net.fabricmc.loom.task.LoomTasks;
|
import net.fabricmc.loom.task.LoomTasks;
|
||||||
|
|
||||||
public class LoomGradlePlugin implements BootstrappedPlugin {
|
public class LoomGradlePlugin implements BootstrappedPlugin {
|
||||||
|
@ -74,7 +76,7 @@ public class LoomGradlePlugin implements BootstrappedPlugin {
|
||||||
project.apply(ImmutableMap.of("plugin", "idea"));
|
project.apply(ImmutableMap.of("plugin", "idea"));
|
||||||
|
|
||||||
// Setup extensions, loom shadows minecraft
|
// Setup extensions, loom shadows minecraft
|
||||||
project.getExtensions().create("minecraft", LoomGradleExtension.class, project);
|
project.getExtensions().create(LoomGradleExtension.class, "minecraft", LoomGradleExtensionImpl.class, project, new LoomFilesImpl(project));
|
||||||
project.getExtensions().add("loom", project.getExtensions().getByName("minecraft"));
|
project.getExtensions().add("loom", project.getExtensions().getByName("minecraft"));
|
||||||
project.getExtensions().create("fabricApi", FabricApiExtension.class, project);
|
project.getExtensions().create("fabricApi", FabricApiExtension.class, project);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* 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.api;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gradle.api.Action;
|
||||||
|
import org.gradle.api.NamedDomainObjectContainer;
|
||||||
|
import org.gradle.api.artifacts.Dependency;
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection;
|
||||||
|
|
||||||
|
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
|
||||||
|
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
||||||
|
import net.fabricmc.loom.configuration.processors.JarProcessor;
|
||||||
|
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the public api available exposed to build scripts.
|
||||||
|
*/
|
||||||
|
public interface LoomGradleExtensionAPI {
|
||||||
|
File getAccessWidener();
|
||||||
|
|
||||||
|
void setAccessWidener(Object file);
|
||||||
|
|
||||||
|
void setShareCaches(boolean shareCaches);
|
||||||
|
|
||||||
|
boolean isShareCaches();
|
||||||
|
|
||||||
|
default void shareCaches() {
|
||||||
|
setShareCaches(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LoomDecompiler> getDecompilers();
|
||||||
|
|
||||||
|
void addDecompiler(LoomDecompiler decompiler);
|
||||||
|
|
||||||
|
List<JarProcessor> getJarProcessors();
|
||||||
|
|
||||||
|
void addJarProcessor(JarProcessor processor);
|
||||||
|
|
||||||
|
ConfigurableFileCollection getLog4jConfigs();
|
||||||
|
|
||||||
|
default Dependency officialMojangMappings() {
|
||||||
|
return layered(LayeredMappingSpecBuilder::officialMojangMappings);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dependency layered(Action<LayeredMappingSpecBuilder> action);
|
||||||
|
|
||||||
|
String getRefmapName();
|
||||||
|
|
||||||
|
void setRefmapName(String refmapName);
|
||||||
|
|
||||||
|
boolean isRemapMod();
|
||||||
|
|
||||||
|
void setRemapMod(boolean remapMod);
|
||||||
|
|
||||||
|
void runs(Action<NamedDomainObjectContainer<RunConfigSettings>> action);
|
||||||
|
|
||||||
|
NamedDomainObjectContainer<RunConfigSettings> getRunConfigs();
|
||||||
|
}
|
|
@ -51,7 +51,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.LoomGradlePlugin;
|
import net.fabricmc.loom.LoomGradlePlugin;
|
||||||
import net.fabricmc.loom.configuration.LoomProjectData;
|
|
||||||
import net.fabricmc.loom.configuration.RemappedConfigurationEntry;
|
import net.fabricmc.loom.configuration.RemappedConfigurationEntry;
|
||||||
import net.fabricmc.loom.configuration.mods.ModProcessor;
|
import net.fabricmc.loom.configuration.mods.ModProcessor;
|
||||||
import net.fabricmc.loom.configuration.processors.dependency.ModDependencyInfo;
|
import net.fabricmc.loom.configuration.processors.dependency.ModDependencyInfo;
|
||||||
|
@ -76,13 +75,11 @@ public class ModCompileRemapper {
|
||||||
DependencyHandler dependencies = project.getDependencies();
|
DependencyHandler dependencies = project.getDependencies();
|
||||||
boolean refreshDeps = LoomGradlePlugin.refreshDeps;
|
boolean refreshDeps = LoomGradlePlugin.refreshDeps;
|
||||||
|
|
||||||
final File modStore = extension.getRemappedModCache();
|
final File modStore = extension.getFiles().getRemappedModCache();
|
||||||
final RemapData remapData = new RemapData(mappingsSuffix, modStore);
|
final RemapData remapData = new RemapData(mappingsSuffix, modStore);
|
||||||
|
|
||||||
final LoomProjectData data = extension.getProjectData();
|
|
||||||
|
|
||||||
for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) {
|
for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) {
|
||||||
data.getLazyConfigurationProvider(entry.getRemappedConfiguration()).configure(remappedConfig -> {
|
extension.getLazyConfigurationProvider(entry.getRemappedConfiguration()).configure(remappedConfig -> {
|
||||||
Configuration sourceConfig = project.getConfigurations().getByName(entry.sourceConfiguration());
|
Configuration sourceConfig = project.getConfigurations().getByName(entry.sourceConfiguration());
|
||||||
Configuration regularConfig = project.getConfigurations().getByName(entry.getTargetConfiguration(project.getConfigurations()));
|
Configuration regularConfig = project.getConfigurations().getByName(entry.getTargetConfiguration(project.getConfigurations()));
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
||||||
|
|
||||||
private void passMixinArguments(T task) {
|
private void passMixinArguments(T task) {
|
||||||
try {
|
try {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
Map<String, String> args = new HashMap<>() {{
|
Map<String, String> args = new HashMap<>() {{
|
||||||
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, extension.getMappingsProvider().tinyMappings.getCanonicalPath());
|
put(Constants.MixinArguments.IN_MAP_FILE_NAMED_INTERMEDIARY, extension.getMappingsProvider().tinyMappings.getCanonicalPath());
|
||||||
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, extension.getNextMixinMappings().getCanonicalPath());
|
put(Constants.MixinArguments.OUT_MAP_FILE_NAMED_INTERMEDIARY, extension.getNextMixinMappings().getCanonicalPath());
|
||||||
|
@ -87,7 +87,7 @@ public abstract class AnnotationProcessorInvoker<T extends Task> {
|
||||||
|
|
||||||
public void configureMixin() {
|
public void configureMixin() {
|
||||||
ConfigurationContainer configs = project.getConfigurations();
|
ConfigurationContainer configs = project.getConfigurations();
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
if (!extension.ideSync()) {
|
if (!extension.ideSync()) {
|
||||||
for (Configuration processorConfig : annotationProcessorConfigurations) {
|
for (Configuration processorConfig : annotationProcessorConfigurations) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class KaptApInvoker extends AnnotationProcessorInvoker<JavaCompile> {
|
||||||
// target location for the refmap and then move it to the correct place for each sourceset
|
// target location for the refmap and then move it to the correct place for each sourceset
|
||||||
task.doLast(t -> {
|
task.doLast(t -> {
|
||||||
try {
|
try {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
Path src = Paths.get(getRefmapDestination(task, extension));
|
Path src = Paths.get(getRefmapDestination(task, extension));
|
||||||
Path dest = Paths.get(task.getDestinationDir().toString(), extension.getRefmapName());
|
Path dest = Paths.get(task.getDestinationDir().toString(), extension.getRefmapName());
|
||||||
|
|
||||||
|
|
|
@ -157,8 +157,8 @@ public final class NestedDependencyProvider implements NestedJarProvider {
|
||||||
|
|
||||||
//A lib that doesnt have a mod.json, we turn it into a fake mod
|
//A lib that doesnt have a mod.json, we turn it into a fake mod
|
||||||
if (!ZipUtil.containsEntry(file, "fabric.mod.json")) {
|
if (!ZipUtil.containsEntry(file, "fabric.mod.json")) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
File tempDir = new File(extension.getUserCache(), "temp/modprocessing");
|
File tempDir = new File(extension.getFiles().getUserCache(), "temp/modprocessing");
|
||||||
|
|
||||||
if (!tempDir.exists()) {
|
if (!tempDir.exists()) {
|
||||||
tempDir.mkdirs();
|
tempDir.mkdirs();
|
||||||
|
|
|
@ -49,30 +49,31 @@ public final class CompileConfiguration {
|
||||||
|
|
||||||
public static void setupConfigurations(Project project) {
|
public static void setupConfigurations(Project project) {
|
||||||
final ConfigurationContainer configurations = project.getConfigurations();
|
final ConfigurationContainer configurations = project.getConfigurations();
|
||||||
LoomProjectData data = project.getExtensions().getByType(LoomGradleExtension.class).getProjectData();
|
|
||||||
|
|
||||||
data.createLazyConfiguration(Constants.Configurations.MOD_COMPILE_CLASSPATH).configure(configuration -> configuration.setTransitive(true));
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
data.createLazyConfiguration(Constants.Configurations.MOD_COMPILE_CLASSPATH_MAPPED).configure(configuration -> configuration.setTransitive(false));
|
|
||||||
data.createLazyConfiguration(Constants.Configurations.MINECRAFT_NAMED).configure(configuration -> configuration.setTransitive(false)); // The launchers do not recurse dependencies
|
extension.createLazyConfiguration(Constants.Configurations.MOD_COMPILE_CLASSPATH).configure(configuration -> configuration.setTransitive(true));
|
||||||
data.createLazyConfiguration(Constants.Configurations.MINECRAFT_DEPENDENCIES).configure(configuration -> configuration.setTransitive(false));
|
extension.createLazyConfiguration(Constants.Configurations.MOD_COMPILE_CLASSPATH_MAPPED).configure(configuration -> configuration.setTransitive(false));
|
||||||
data.createLazyConfiguration(Constants.Configurations.LOADER_DEPENDENCIES).configure(configuration -> configuration.setTransitive(false));
|
extension.createLazyConfiguration(Constants.Configurations.MINECRAFT_NAMED).configure(configuration -> configuration.setTransitive(false)); // The launchers do not recurse dependencies
|
||||||
data.createLazyConfiguration(Constants.Configurations.MINECRAFT).configure(configuration -> configuration.setTransitive(false));
|
extension.createLazyConfiguration(Constants.Configurations.MINECRAFT_DEPENDENCIES).configure(configuration -> configuration.setTransitive(false));
|
||||||
data.createLazyConfiguration(Constants.Configurations.INCLUDE).configure(configuration -> configuration.setTransitive(false)); // Dont get transitive deps
|
extension.createLazyConfiguration(Constants.Configurations.LOADER_DEPENDENCIES).configure(configuration -> configuration.setTransitive(false));
|
||||||
data.createLazyConfiguration(Constants.Configurations.MAPPING_CONSTANTS);
|
extension.createLazyConfiguration(Constants.Configurations.MINECRAFT).configure(configuration -> configuration.setTransitive(false));
|
||||||
|
extension.createLazyConfiguration(Constants.Configurations.INCLUDE).configure(configuration -> configuration.setTransitive(false)); // Dont get transitive deps
|
||||||
|
extension.createLazyConfiguration(Constants.Configurations.MAPPING_CONSTANTS);
|
||||||
|
|
||||||
extendsFrom(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, Constants.Configurations.MAPPING_CONSTANTS, project);
|
extendsFrom(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, Constants.Configurations.MAPPING_CONSTANTS, project);
|
||||||
|
|
||||||
data.createLazyConfiguration(Constants.Configurations.MAPPINGS);
|
extension.createLazyConfiguration(Constants.Configurations.MAPPINGS);
|
||||||
data.createLazyConfiguration(Constants.Configurations.MAPPINGS_FINAL);
|
extension.createLazyConfiguration(Constants.Configurations.MAPPINGS_FINAL);
|
||||||
data.createLazyConfiguration(Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES);
|
extension.createLazyConfiguration(Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES);
|
||||||
data.createLazyConfiguration(Constants.Configurations.UNPICK_CLASSPATH);
|
extension.createLazyConfiguration(Constants.Configurations.UNPICK_CLASSPATH);
|
||||||
|
|
||||||
for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) {
|
for (RemappedConfigurationEntry entry : Constants.MOD_COMPILE_ENTRIES) {
|
||||||
data.createLazyConfiguration(entry.sourceConfiguration())
|
extension.createLazyConfiguration(entry.sourceConfiguration())
|
||||||
.configure(configuration -> configuration.setTransitive(true));
|
.configure(configuration -> configuration.setTransitive(true));
|
||||||
|
|
||||||
// Don't get transitive deps of already remapped mods
|
// Don't get transitive deps of already remapped mods
|
||||||
data.createLazyConfiguration(entry.getRemappedConfiguration())
|
extension.createLazyConfiguration(entry.getRemappedConfiguration())
|
||||||
.configure(configuration -> configuration.setTransitive(false));
|
.configure(configuration -> configuration.setTransitive(false));
|
||||||
|
|
||||||
extendsFrom(entry.getTargetConfiguration(configurations), entry.getRemappedConfiguration(), project);
|
extendsFrom(entry.getTargetConfiguration(configurations), entry.getRemappedConfiguration(), project);
|
||||||
|
@ -111,7 +112,7 @@ public final class CompileConfiguration {
|
||||||
});
|
});
|
||||||
|
|
||||||
p.afterEvaluate(project -> {
|
p.afterEvaluate(project -> {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
LoomDependencyManager dependencyManager = new LoomDependencyManager();
|
LoomDependencyManager dependencyManager = new LoomDependencyManager();
|
||||||
extension.setDependencyManager(dependencyManager);
|
extension.setDependencyManager(dependencyManager);
|
||||||
|
@ -129,7 +130,7 @@ public final class CompileConfiguration {
|
||||||
SetupIntelijRunConfigs.setup(project);
|
SetupIntelijRunConfigs.setup(project);
|
||||||
|
|
||||||
// Enables the default mod remapper
|
// Enables the default mod remapper
|
||||||
if (extension.remapMod) {
|
if (extension.isRemapMod()) {
|
||||||
RemapConfiguration.setupDefaultRemap(project);
|
RemapConfiguration.setupDefaultRemap(project);
|
||||||
} else {
|
} else {
|
||||||
Jar jarTask = (Jar) project.getTasks().getByName("jar");
|
Jar jarTask = (Jar) project.getTasks().getByName("jar");
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.zeroturnaround.zip.ZipUtil;
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.LoomGradlePlugin;
|
import net.fabricmc.loom.LoomGradlePlugin;
|
||||||
|
import net.fabricmc.loom.extension.LoomFiles;
|
||||||
|
|
||||||
public abstract class DependencyProvider {
|
public abstract class DependencyProvider {
|
||||||
private LoomDependencyManager dependencyManager;
|
private LoomDependencyManager dependencyManager;
|
||||||
|
@ -57,7 +58,7 @@ public abstract class DependencyProvider {
|
||||||
|
|
||||||
public DependencyProvider(Project project) {
|
public DependencyProvider(Project project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
this.extension = LoomGradleExtension.get(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception;
|
public abstract void provide(DependencyInfo dependency, Consumer<Runnable> postPopulationScheduler) throws Exception;
|
||||||
|
@ -88,6 +89,10 @@ public abstract class DependencyProvider {
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoomFiles getDirectories() {
|
||||||
|
return getExtension().getFiles();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isRefreshDeps() {
|
public boolean isRefreshDeps() {
|
||||||
return LoomGradlePlugin.refreshDeps;
|
return LoomGradlePlugin.refreshDeps;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,9 +103,9 @@ public class FabricApiExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getApiMavenPom(String fabricApiVersion) {
|
private File getApiMavenPom(String fabricApiVersion) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
File mavenPom = new File(extension.getUserCache(), "fabric-api/" + fabricApiVersion + ".pom");
|
File mavenPom = new File(extension.getFiles().getUserCache(), "fabric-api/" + fabricApiVersion + ".pom");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL url = new URL(String.format("https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/%1$s/fabric-api-%1$s.pom", fabricApiVersion));
|
URL url = new URL(String.format("https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/%1$s/fabric-api-%1$s.pom", fabricApiVersion));
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final record JarManifestConfiguration(Project project) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
Attributes attributes = manifest.getMainAttributes();
|
Attributes attributes = manifest.getMainAttributes();
|
||||||
var tinyRemapperVersion = Optional.ofNullable(TinyRemapper.class.getPackage().getImplementationVersion());
|
var tinyRemapperVersion = Optional.ofNullable(TinyRemapper.class.getPackage().getImplementationVersion());
|
||||||
|
@ -79,7 +79,7 @@ public final record JarManifestConfiguration(Project project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<String> getLoaderVersion() {
|
private Optional<String> getLoaderVersion() {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
if (extension.getInstallerData() == null) {
|
if (extension.getInstallerData() == null) {
|
||||||
project.getLogger().warn("Could not determine fabric loader version for jar manifest");
|
project.getLogger().warn("Could not determine fabric loader version for jar manifest");
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class LoomDependencyManager {
|
||||||
MappingsProviderImpl mappingsProvider = null;
|
MappingsProviderImpl mappingsProvider = null;
|
||||||
|
|
||||||
project.getLogger().info(":setting up loom dependencies");
|
project.getLogger().info(":setting up loom dependencies");
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
Map<String, ProviderList> providerListMap = new HashMap<>();
|
Map<String, ProviderList> providerListMap = new HashMap<>();
|
||||||
List<ProviderList> targetProviders = new ArrayList<>();
|
List<ProviderList> targetProviders = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public class LoomDependencyManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleInstallerJson(JsonObject jsonObject, Project project) {
|
private static void handleInstallerJson(JsonObject jsonObject, Project project) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
JsonObject libraries = jsonObject.get("libraries").getAsJsonObject();
|
JsonObject libraries = jsonObject.get("libraries").getAsJsonObject();
|
||||||
Configuration loaderDepsConfig = project.getConfigurations().getByName(Constants.Configurations.LOADER_DEPENDENCIES);
|
Configuration loaderDepsConfig = project.getConfigurations().getByName(Constants.Configurations.LOADER_DEPENDENCIES);
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016-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.configuration;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.gradle.api.NamedDomainObjectProvider;
|
|
||||||
import org.gradle.api.Project;
|
|
||||||
import org.gradle.api.artifacts.Configuration;
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
|
|
||||||
@ApiStatus.Internal
|
|
||||||
/**
|
|
||||||
* This class is stored in the gradle extension, and should not be used outside of loom.
|
|
||||||
* It contains data/info related to the current project
|
|
||||||
*/
|
|
||||||
public final class LoomProjectData {
|
|
||||||
private final Project project;
|
|
||||||
private final Map<String, NamedDomainObjectProvider<Configuration>> lazyConfigurations = new HashMap<>();
|
|
||||||
|
|
||||||
public LoomProjectData(Project project) {
|
|
||||||
this.project = Objects.requireNonNull(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NamedDomainObjectProvider<Configuration> createLazyConfiguration(String name) {
|
|
||||||
NamedDomainObjectProvider<Configuration> provider = project.getConfigurations().register(name);
|
|
||||||
|
|
||||||
if (lazyConfigurations.containsKey(name)) {
|
|
||||||
throw new IllegalStateException("Duplicate configuration name" + name);
|
|
||||||
}
|
|
||||||
|
|
||||||
lazyConfigurations.put(name, provider);
|
|
||||||
|
|
||||||
return provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NamedDomainObjectProvider<Configuration> getLazyConfigurationProvider(String name) {
|
|
||||||
NamedDomainObjectProvider<Configuration> provider = lazyConfigurations.get(name);
|
|
||||||
|
|
||||||
if (provider == null) {
|
|
||||||
throw new NullPointerException("Could not find provider with name: " + name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return provider;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -63,7 +63,7 @@ public class RemapConfiguration {
|
||||||
|
|
||||||
// isDefaultRemap is set to true for the standard remap task, some defaults are left out when this is false.
|
// isDefaultRemap is set to true for the standard remap task, some defaults are left out when this is false.
|
||||||
private static void setupRemap(Project project, boolean isDefaultRemap, String jarTaskName, String sourcesJarTaskName, String remapJarTaskName, String remapSourcesJarTaskName, String remapAllJarsTaskName, String remapAllSourcesTaskName) {
|
private static void setupRemap(Project project, boolean isDefaultRemap, String jarTaskName, String sourcesJarTaskName, String remapJarTaskName, String remapSourcesJarTaskName, String remapAllJarsTaskName, String remapAllSourcesTaskName) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
AbstractArchiveTask jarTask = (AbstractArchiveTask) project.getTasks().getByName(jarTaskName);
|
AbstractArchiveTask jarTask = (AbstractArchiveTask) project.getTasks().getByName(jarTaskName);
|
||||||
RemapJarTask remapJarTask = (RemapJarTask) project.getTasks().findByName(remapJarTaskName);
|
RemapJarTask remapJarTask = (RemapJarTask) project.getTasks().findByName(remapJarTaskName);
|
||||||
|
|
||||||
|
|
|
@ -71,15 +71,15 @@ public class AccessWidenerJarProcessor implements JarProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
LoomGradleExtension loomGradleExtension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension loomGradleExtension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
if (!loomGradleExtension.accessWidener.exists()) {
|
if (!loomGradleExtension.getAccessWidener().exists()) {
|
||||||
throw new RuntimeException("Could not find access widener file @ " + loomGradleExtension.accessWidener.getAbsolutePath());
|
throw new RuntimeException("Could not find access widener file @ " + loomGradleExtension.getAccessWidener().getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
inputHash = Checksum.sha256(loomGradleExtension.accessWidener);
|
inputHash = Checksum.sha256(loomGradleExtension.getAccessWidener());
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(loomGradleExtension.accessWidener))) {
|
try (BufferedReader reader = new BufferedReader(new FileReader(loomGradleExtension.getAccessWidener()))) {
|
||||||
accessWidenerReader.read(reader);
|
accessWidenerReader.read(reader);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to read project access widener file");
|
throw new RuntimeException("Failed to read project access widener file");
|
||||||
|
|
|
@ -27,12 +27,10 @@ package net.fabricmc.loom.configuration.ide;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
@ -44,7 +42,6 @@ import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.util.Constants;
|
|
||||||
import net.fabricmc.loom.util.OperatingSystem;
|
import net.fabricmc.loom.util.OperatingSystem;
|
||||||
|
|
||||||
public class RunConfig {
|
public class RunConfig {
|
||||||
|
@ -110,42 +107,8 @@ public class RunConfig {
|
||||||
runConfig.vmArgs = "";
|
runConfig.vmArgs = "";
|
||||||
runConfig.programArgs = "";
|
runConfig.programArgs = "";
|
||||||
|
|
||||||
if ("launchwrapper".equals(extension.getLoaderLaunchMethod())) {
|
runConfig.mainClass = "net.fabricmc.devlaunchinjector.Main";
|
||||||
runConfig.mainClass = "net.minecraft.launchwrapper.Launch"; // TODO What about custom tweakers for run configs?
|
runConfig.vmArgs = "-XX:+ShowCodeDetailsInExceptionMessages -Dfabric.dli.config=" + encodeEscaped(extension.getFiles().getDevLauncherConfig().getAbsolutePath()) + " -Dfabric.dli.env=" + environment.toLowerCase();
|
||||||
runConfig.programArgs += "--tweakClass " + ("client".equals(environment) ? Constants.LaunchWrapper.DEFAULT_FABRIC_CLIENT_TWEAKER : Constants.LaunchWrapper.DEFAULT_FABRIC_SERVER_TWEAKER);
|
|
||||||
} else {
|
|
||||||
runConfig.mainClass = "net.fabricmc.devlaunchinjector.Main";
|
|
||||||
runConfig.vmArgs = "-XX:+ShowCodeDetailsInExceptionMessages -Dfabric.dli.config=" + encodeEscaped(extension.getDevLauncherConfig().getAbsolutePath()) + " -Dfabric.dli.env=" + environment.toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extension.getLoaderLaunchMethod().equals("launchwrapper")) {
|
|
||||||
// if installer.json found...
|
|
||||||
JsonObject installerJson = extension.getInstallerData().installerJson();
|
|
||||||
|
|
||||||
if (installerJson != null) {
|
|
||||||
List<String> sideKeys = ImmutableList.of(environment, "common");
|
|
||||||
|
|
||||||
// copy launchwrapper tweakers
|
|
||||||
if (installerJson.has("launchwrapper")) {
|
|
||||||
JsonObject launchwrapperJson = installerJson.getAsJsonObject("launchwrapper");
|
|
||||||
|
|
||||||
if (launchwrapperJson.has("tweakers")) {
|
|
||||||
JsonObject tweakersJson = launchwrapperJson.getAsJsonObject("tweakers");
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
for (String s : sideKeys) {
|
|
||||||
if (tweakersJson.has(s)) {
|
|
||||||
for (JsonElement element : tweakersJson.getAsJsonArray(s)) {
|
|
||||||
builder.append(" --tweakClass ").append(element.getAsString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
runConfig.programArgs += builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turns camelCase/PascalCase into Capital Case
|
// Turns camelCase/PascalCase into Capital Case
|
||||||
|
@ -159,7 +122,7 @@ public class RunConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RunConfig runConfig(Project project, RunConfigSettings settings) {
|
public static RunConfig runConfig(Project project, RunConfigSettings settings) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
String name = settings.getName();
|
String name = settings.getName();
|
||||||
|
|
||||||
String configName = settings.getConfigName();
|
String configName = settings.getConfigName();
|
||||||
|
@ -264,11 +227,6 @@ public class RunConfig {
|
||||||
return mainClassName;
|
return mainClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to default class names, happens when in a loader dev env
|
|
||||||
if ("launchwrapper".equals(extension.getLoaderLaunchMethod())) {
|
|
||||||
return "net.minecraft.launchwrapper.Launch";
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultMainClass;
|
return defaultMainClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ public final class RunConfigSettings implements Named {
|
||||||
public RunConfigSettings(Project project, String baseName) {
|
public RunConfigSettings(Project project, String baseName) {
|
||||||
this.baseName = baseName;
|
this.baseName = baseName;
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
this.extension = LoomGradleExtension.get(project);
|
||||||
this.ideConfigGenerated = extension.isRootProject();
|
this.ideConfigGenerated = extension.isRootProject();
|
||||||
|
|
||||||
source("main");
|
source("main");
|
||||||
|
|
|
@ -37,7 +37,7 @@ import net.fabricmc.loom.configuration.providers.minecraft.assets.MinecraftAsset
|
||||||
|
|
||||||
public class SetupIntelijRunConfigs {
|
public class SetupIntelijRunConfigs {
|
||||||
public static void setup(Project project) {
|
public static void setup(Project project) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
File projectDir = project.getRootProject().file(".idea");
|
File projectDir = project.getRootProject().file(".idea");
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class SetupIntelijRunConfigs {
|
||||||
|
|
||||||
private static void generate(Project project) throws IOException {
|
private static void generate(Project project) throws IOException {
|
||||||
Project rootProject = project.getRootProject();
|
Project rootProject = project.getRootProject();
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
if (extension.ideSync()) {
|
if (extension.ideSync()) {
|
||||||
//Ensures the assets are downloaded when idea is syncing a project
|
//Ensures the assets are downloaded when idea is syncing a project
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class ModProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void remapJars(Project project, List<ModDependencyInfo> processList) throws IOException {
|
private static void remapJars(Project project, List<ModDependencyInfo> processList) throws IOException {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
String fromM = "intermediary";
|
String fromM = "intermediary";
|
||||||
String toM = "named";
|
String toM = "named";
|
||||||
|
|
||||||
|
@ -210,28 +210,15 @@ public class ModProcessor {
|
||||||
|
|
||||||
public static JsonObject readInstallerJson(File file, Project project) {
|
public static JsonObject readInstallerJson(File file, Project project) {
|
||||||
try {
|
try {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
String launchMethod = extension.getLoaderLaunchMethod();
|
|
||||||
|
|
||||||
String jsonStr;
|
String jsonStr;
|
||||||
|
|
||||||
try (JarFile jarFile = new JarFile(file)) {
|
try (JarFile jarFile = new JarFile(file)) {
|
||||||
ZipEntry entry = null;
|
ZipEntry entry = jarFile.getEntry("fabric-installer.json");
|
||||||
|
|
||||||
if (!launchMethod.isEmpty()) {
|
|
||||||
entry = jarFile.getEntry("fabric-installer." + launchMethod + ".json");
|
|
||||||
|
|
||||||
if (entry == null) {
|
|
||||||
project.getLogger().warn("Could not find loader launch method '" + launchMethod + "', falling back");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
entry = jarFile.getEntry("fabric-installer.json");
|
return null;
|
||||||
|
|
||||||
if (entry == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try (InputStream inputstream = jarFile.getInputStream(entry)) {
|
try (InputStream inputstream = jarFile.getInputStream(entry)) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class MinecraftProcessedProvider extends MinecraftMappedProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidateJars() {
|
private void invalidateJars() {
|
||||||
File dir = getJarDirectory(getExtension().getUserCache(), projectMappedClassifier);
|
File dir = getJarDirectory(getExtension().getFiles().getUserCache(), projectMappedClassifier);
|
||||||
|
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
getProject().getLogger().warn("Invalidating project jars");
|
getProject().getLogger().warn("Invalidating project jars");
|
||||||
|
@ -87,7 +87,7 @@ public class MinecraftProcessedProvider extends MinecraftMappedProvider {
|
||||||
public void initFiles(MinecraftProviderImpl minecraftProvider, MappingsProviderImpl mappingsProvider) {
|
public void initFiles(MinecraftProviderImpl minecraftProvider, MappingsProviderImpl mappingsProvider) {
|
||||||
super.initFiles(minecraftProvider, mappingsProvider);
|
super.initFiles(minecraftProvider, mappingsProvider);
|
||||||
|
|
||||||
projectMappedJar = new File(getJarDirectory(getExtension().getRootProjectPersistentCache(), projectMappedClassifier), "minecraft-" + getJarVersionString(projectMappedClassifier) + ".jar");
|
projectMappedJar = new File(getJarDirectory(getExtension().getFiles().getRootProjectPersistentCache(), projectMappedClassifier), "minecraft-" + getJarVersionString(projectMappedClassifier) + ".jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,13 +58,13 @@ public class LaunchProvider extends DependencyProvider {
|
||||||
.property("fabric.remapClasspathFile", getRemapClasspathFile().getAbsolutePath())
|
.property("fabric.remapClasspathFile", getRemapClasspathFile().getAbsolutePath())
|
||||||
.property("log4j.configurationFile", getAllLog4JConfigFiles())
|
.property("log4j.configurationFile", getAllLog4JConfigFiles())
|
||||||
|
|
||||||
.property("client", "java.library.path", getExtension().getNativesDirectory().getAbsolutePath())
|
.property("client", "java.library.path", getDirectories().getNativesDirectory(getExtension().getMinecraftProvider()).getAbsolutePath())
|
||||||
.property("client", "org.lwjgl.librarypath", getExtension().getNativesDirectory().getAbsolutePath())
|
.property("client", "org.lwjgl.librarypath", getDirectories().getNativesDirectory(getExtension().getMinecraftProvider()).getAbsolutePath())
|
||||||
|
|
||||||
.argument("client", "--assetIndex")
|
.argument("client", "--assetIndex")
|
||||||
.argument("client", getExtension().getMinecraftProvider().getVersionInfo().assetIndex().fabricId(getExtension().getMinecraftProvider().minecraftVersion()))
|
.argument("client", getExtension().getMinecraftProvider().getVersionInfo().assetIndex().fabricId(getExtension().getMinecraftProvider().minecraftVersion()))
|
||||||
.argument("client", "--assetsDir")
|
.argument("client", "--assetsDir")
|
||||||
.argument("client", new File(getExtension().getUserCache(), "assets").getAbsolutePath());
|
.argument("client", new File(getDirectories().getUserCache(), "assets").getAbsolutePath());
|
||||||
|
|
||||||
//Enable ansi by default for idea and vscode
|
//Enable ansi by default for idea and vscode
|
||||||
if (new File(getProject().getRootDir(), ".vscode").exists()
|
if (new File(getProject().getRootDir(), ".vscode").exists()
|
||||||
|
@ -74,7 +74,7 @@ public class LaunchProvider extends DependencyProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
writeLog4jConfig();
|
writeLog4jConfig();
|
||||||
FileUtils.writeStringToFile(getExtension().getDevLauncherConfig(), launchConfig.asString(), StandardCharsets.UTF_8);
|
FileUtils.writeStringToFile(getDirectories().getDevLauncherConfig(), launchConfig.asString(), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
addDependency(Constants.Dependencies.DEV_LAUNCH_INJECTOR + Constants.Dependencies.Versions.DEV_LAUNCH_INJECTOR, Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES);
|
addDependency(Constants.Dependencies.DEV_LAUNCH_INJECTOR + Constants.Dependencies.Versions.DEV_LAUNCH_INJECTOR, Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES);
|
||||||
addDependency(Constants.Dependencies.TERMINAL_CONSOLE_APPENDER + Constants.Dependencies.Versions.TERMINAL_CONSOLE_APPENDER, Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES);
|
addDependency(Constants.Dependencies.TERMINAL_CONSOLE_APPENDER + Constants.Dependencies.Versions.TERMINAL_CONSOLE_APPENDER, Constants.Configurations.LOOM_DEVELOPMENT_DEPENDENCIES);
|
||||||
|
@ -84,7 +84,7 @@ public class LaunchProvider extends DependencyProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getLog4jConfigFile() {
|
private File getLog4jConfigFile() {
|
||||||
return getExtension().getDefaultLog4jConfigFile();
|
return getDirectories().getDefaultLog4jConfigFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAllLog4JConfigFiles() {
|
private String getAllLog4JConfigFiles() {
|
||||||
|
@ -94,7 +94,7 @@ public class LaunchProvider extends DependencyProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getRemapClasspathFile() {
|
private File getRemapClasspathFile() {
|
||||||
return new File(getExtension().getDevLauncherConfig().getParentFile(), "remapClasspath.txt");
|
return new File(getDirectories().getDevLauncherConfig().getParentFile(), "remapClasspath.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeLog4jConfig() {
|
private void writeLog4jConfig() {
|
||||||
|
|
|
@ -111,11 +111,11 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFiles() {
|
private void initFiles() {
|
||||||
minecraftJson = new File(getExtension().getUserCache(), "minecraft-" + minecraftVersion + "-info.json");
|
minecraftJson = new File(getDirectories().getUserCache(), "minecraft-" + minecraftVersion + "-info.json");
|
||||||
minecraftClientJar = new File(getExtension().getUserCache(), "minecraft-" + minecraftVersion + "-client.jar");
|
minecraftClientJar = new File(getDirectories().getUserCache(), "minecraft-" + minecraftVersion + "-client.jar");
|
||||||
minecraftServerJar = new File(getExtension().getUserCache(), "minecraft-" + minecraftVersion + "-server.jar");
|
minecraftServerJar = new File(getDirectories().getUserCache(), "minecraft-" + minecraftVersion + "-server.jar");
|
||||||
minecraftMergedJar = new File(getExtension().getUserCache(), "minecraft-" + minecraftVersion + "-merged.jar");
|
minecraftMergedJar = new File(getDirectories().getUserCache(), "minecraft-" + minecraftVersion + "-merged.jar");
|
||||||
versionManifestJson = new File(getExtension().getUserCache(), "version_manifest.json");
|
versionManifestJson = new File(getDirectories().getUserCache(), "version_manifest.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadMcJson(boolean offline) throws IOException {
|
private void downloadMcJson(boolean offline) throws IOException {
|
||||||
|
@ -143,10 +143,10 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||||
|
|
||||||
Optional<ManifestVersion.Versions> optionalVersion = Optional.empty();
|
Optional<ManifestVersion.Versions> optionalVersion = Optional.empty();
|
||||||
|
|
||||||
if (getExtension().customManifest != null) {
|
if (getExtension().getCustomManifest() != null) {
|
||||||
ManifestVersion.Versions customVersion = new ManifestVersion.Versions();
|
ManifestVersion.Versions customVersion = new ManifestVersion.Versions();
|
||||||
customVersion.id = minecraftVersion;
|
customVersion.id = minecraftVersion;
|
||||||
customVersion.url = getExtension().customManifest;
|
customVersion.url = getExtension().getCustomManifest();
|
||||||
optionalVersion = Optional.of(customVersion);
|
optionalVersion = Optional.of(customVersion);
|
||||||
getProject().getLogger().lifecycle("Using custom minecraft manifest");
|
getProject().getLogger().lifecycle("Using custom minecraft manifest");
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public class MinecraftProviderImpl extends DependencyProvider implements Minecra
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasRecentValidManifest() throws IOException {
|
private boolean hasRecentValidManifest() throws IOException {
|
||||||
if (getExtension().customManifest != null) {
|
if (getExtension().getCustomManifest() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class GradleMappingContext implements MappingContext {
|
||||||
|
|
||||||
public GradleMappingContext(Project project, String workingDirName) {
|
public GradleMappingContext(Project project, String workingDirName) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
this.extension = LoomGradleExtension.get(project);
|
||||||
this.workingDirName = workingDirName;
|
this.workingDirName = workingDirName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
|
|
||||||
public MappingsProviderImpl(Project project) {
|
public MappingsProviderImpl(Project project) {
|
||||||
super(project);
|
super(project);
|
||||||
mappingsDir = getExtension().getUserCache().toPath().resolve("mappings");
|
mappingsDir = getDirectories().getUserCache().toPath().resolve("mappings");
|
||||||
mappingsStepsDir = mappingsDir.resolve("steps");
|
mappingsStepsDir = mappingsDir.resolve("steps");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
|
|
||||||
tinyMappings = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".tiny").toFile();
|
tinyMappings = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".tiny").toFile();
|
||||||
unpickDefinitionsFile = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".unpick").toFile();
|
unpickDefinitionsFile = mappingsDir.resolve(StringUtils.removeSuffix(mappingsJar.getName(), ".jar") + ".unpick").toFile();
|
||||||
tinyMappingsJar = new File(getExtension().getUserCache(), mappingsJar.getName().replace(".jar", "-" + jarClassifier + ".jar"));
|
tinyMappingsJar = new File(getDirectories().getUserCache(), mappingsJar.getName().replace(".jar", "-" + jarClassifier + ".jar"));
|
||||||
|
|
||||||
if (!tinyMappings.exists() || isRefreshDeps()) {
|
if (!tinyMappings.exists() || isRefreshDeps()) {
|
||||||
storeMappings(getProject(), minecraftProvider, mappingsJar.toPath());
|
storeMappings(getProject(), minecraftProvider, mappingsJar.toPath());
|
||||||
|
@ -177,7 +177,7 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
|
|
||||||
LoomGradleExtension extension = getExtension();
|
LoomGradleExtension extension = getExtension();
|
||||||
|
|
||||||
if (extension.accessWidener != null) {
|
if (extension.getAccessWidener() != null) {
|
||||||
extension.addJarProcessor(new AccessWidenerJarProcessor(getProject()));
|
extension.addJarProcessor(new AccessWidenerJarProcessor(getProject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||||
|
|
||||||
// Download and extract intermediary
|
// Download and extract intermediary
|
||||||
String encodedMinecraftVersion = UrlEscapers.urlFragmentEscaper().escape(minecraftVersion);
|
String encodedMinecraftVersion = UrlEscapers.urlFragmentEscaper().escape(minecraftVersion);
|
||||||
String intermediaryArtifactUrl = getExtension().getIntermediaryUrl().apply(encodedMinecraftVersion);
|
String intermediaryArtifactUrl = getExtension().getIntermediaryUrl(encodedMinecraftVersion);
|
||||||
Path intermediaryJar = mappingsDir.resolve("v2-intermediary-" + minecraftVersion + ".jar");
|
Path intermediaryJar = mappingsDir.resolve("v2-intermediary-" + minecraftVersion + ".jar");
|
||||||
DownloadUtil.downloadIfChanged(new URL(intermediaryArtifactUrl), intermediaryJar.toFile(), getProject().getLogger());
|
DownloadUtil.downloadIfChanged(new URL(intermediaryArtifactUrl), intermediaryJar.toFile(), getProject().getLogger());
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class MinecraftLibraryProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFiles(Project project, MinecraftProviderImpl minecraftProvider) {
|
private void initFiles(Project project, MinecraftProviderImpl minecraftProvider) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
MINECRAFT_LIBS = new File(extension.getUserCache(), "libraries");
|
MINECRAFT_LIBS = new File(extension.getFiles().getUserCache(), "libraries");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,8 +150,8 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||||
|
|
||||||
public void initFiles(MinecraftProviderImpl minecraftProvider, MappingsProviderImpl mappingsProvider) {
|
public void initFiles(MinecraftProviderImpl minecraftProvider, MappingsProviderImpl mappingsProvider) {
|
||||||
this.minecraftProvider = minecraftProvider;
|
this.minecraftProvider = minecraftProvider;
|
||||||
minecraftIntermediaryJar = new File(getExtension().getUserCache(), "minecraft-" + getJarVersionString("intermediary") + ".jar");
|
minecraftIntermediaryJar = new File(getDirectories().getUserCache(), "minecraft-" + getJarVersionString("intermediary") + ".jar");
|
||||||
minecraftMappedJar = new File(getJarDirectory(getExtension().getUserCache(), "mapped"), "minecraft-" + getJarVersionString("mapped") + ".jar");
|
minecraftMappedJar = new File(getJarDirectory(getDirectories().getUserCache(), "mapped"), "minecraft-" + getJarVersionString("mapped") + ".jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected File getJarDirectory(File parentDirectory, String type) {
|
protected File getJarDirectory(File parentDirectory, String type) {
|
||||||
|
@ -171,7 +171,7 @@ public class MinecraftMappedProvider extends DependencyProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getUnpickedJar() {
|
public File getUnpickedJar() {
|
||||||
return new File(getJarDirectory(getExtension().getUserCache(), "mapped"), "minecraft-" + getJarVersionString("unpicked") + ".jar");
|
return new File(getJarDirectory(getDirectories().getUserCache(), "mapped"), "minecraft-" + getJarVersionString("unpicked") + ".jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -49,10 +49,10 @@ public class MinecraftNativesProvider {
|
||||||
|
|
||||||
public MinecraftNativesProvider(Project project) {
|
public MinecraftNativesProvider(Project project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
nativesDir = extension.getNativesDirectory();
|
nativesDir = extension.getFiles().getNativesDirectory(extension.getMinecraftProvider());
|
||||||
jarStore = extension.getNativesJarStore();
|
jarStore = extension.getFiles().getNativesJarStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void provide(Project project) throws IOException {
|
public static void provide(Project project) throws IOException {
|
||||||
|
@ -60,7 +60,7 @@ public class MinecraftNativesProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void provide() throws IOException {
|
private void provide() throws IOException {
|
||||||
if (extension.hasCustomNatives()) {
|
if (extension.getFiles().hasCustomNatives()) {
|
||||||
if (!nativesDir.exists()) {
|
if (!nativesDir.exists()) {
|
||||||
throw new RuntimeException("Could no find custom natives directory at " + nativesDir.getAbsolutePath());
|
throw new RuntimeException("Could no find custom natives directory at " + nativesDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,14 +49,14 @@ import net.fabricmc.loom.util.gradle.ProgressLogger;
|
||||||
|
|
||||||
public class MinecraftAssetsProvider {
|
public class MinecraftAssetsProvider {
|
||||||
public static void provide(MinecraftProviderImpl minecraftProvider, Project project) throws IOException {
|
public static void provide(MinecraftProviderImpl minecraftProvider, Project project) throws IOException {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
boolean offline = project.getGradle().getStartParameter().isOffline();
|
boolean offline = project.getGradle().getStartParameter().isOffline();
|
||||||
|
|
||||||
MinecraftVersionMeta versionInfo = minecraftProvider.getVersionInfo();
|
MinecraftVersionMeta versionInfo = minecraftProvider.getVersionInfo();
|
||||||
MinecraftVersionMeta.AssetIndex assetIndex = versionInfo.assetIndex();
|
MinecraftVersionMeta.AssetIndex assetIndex = versionInfo.assetIndex();
|
||||||
|
|
||||||
// get existing cache files
|
// get existing cache files
|
||||||
File assets = new File(extension.getUserCache(), "assets");
|
File assets = new File(extension.getFiles().getUserCache(), "assets");
|
||||||
|
|
||||||
if (!assets.exists()) {
|
if (!assets.exists()) {
|
||||||
assets.mkdirs();
|
assets.mkdirs();
|
||||||
|
|
|
@ -35,7 +35,7 @@ public final class DecompilerConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setup(Project project) {
|
public static void setup(Project project) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
extension.addDecompiler(new FabricFernFlowerDecompiler(project));
|
extension.addDecompiler(new FabricFernFlowerDecompiler(project));
|
||||||
extension.addDecompiler(new FabricCFRDecompiler(project));
|
extension.addDecompiler(new FabricCFRDecompiler(project));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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 java.io.File;
|
||||||
|
|
||||||
|
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||||
|
|
||||||
|
public interface LoomFiles {
|
||||||
|
File getUserCache();
|
||||||
|
File getRootProjectPersistentCache();
|
||||||
|
File getProjectPersistentCache();
|
||||||
|
File getProjectBuildCache();
|
||||||
|
File getRemappedModCache();
|
||||||
|
File getNativesJarStore();
|
||||||
|
boolean hasCustomNatives();
|
||||||
|
File getNativesDirectory(MinecraftProvider minecraftProvider);
|
||||||
|
File getDefaultLog4jConfigFile();
|
||||||
|
File getDevLauncherConfig();
|
||||||
|
File getUnpickLoggingConfigFile();
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
/*
|
||||||
|
* 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 java.io.File;
|
||||||
|
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
|
||||||
|
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||||
|
|
||||||
|
public final class LoomFilesImpl implements LoomFiles {
|
||||||
|
private final Project project;
|
||||||
|
|
||||||
|
private final File userCache;
|
||||||
|
private final File rootProjectPersistentCache;
|
||||||
|
private final File projectPersistentCache;
|
||||||
|
private final File projectBuildCache;
|
||||||
|
private final File remappedModCache;
|
||||||
|
private final File nativesJarStore;
|
||||||
|
|
||||||
|
public LoomFilesImpl(Project project) {
|
||||||
|
this.project = project;
|
||||||
|
|
||||||
|
this.userCache = createFile(project.getGradle().getGradleUserHomeDir(), "caches" + File.separator + "fabric-loom");
|
||||||
|
this.rootProjectPersistentCache = createFile(project.getRootProject().file(".gradle"), "loom-cache");
|
||||||
|
this.projectPersistentCache = createFile(project.file(".gradle"), "loom-cache");
|
||||||
|
this.projectBuildCache = createFile(project.getBuildDir(), "loom-cache");
|
||||||
|
this.remappedModCache = createFile(getRootProjectPersistentCache(), "remapped_mods");
|
||||||
|
this.nativesJarStore = createFile(getUserCache(), "natives/jars");
|
||||||
|
}
|
||||||
|
|
||||||
|
private File createFile(File parent, String child) {
|
||||||
|
File file = new File(parent, child);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getUserCache() {
|
||||||
|
return userCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getRootProjectPersistentCache() {
|
||||||
|
return rootProjectPersistentCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getProjectPersistentCache() {
|
||||||
|
return projectPersistentCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getProjectBuildCache() {
|
||||||
|
return projectBuildCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getRemappedModCache() {
|
||||||
|
return remappedModCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getNativesJarStore() {
|
||||||
|
return nativesJarStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomNatives() {
|
||||||
|
return project.getProperties().get("fabric.loom.natives.dir") != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getNativesDirectory(MinecraftProvider minecraftProvider) {
|
||||||
|
if (hasCustomNatives()) {
|
||||||
|
return new File((String) project.property("fabric.loom.natives.dir"));
|
||||||
|
}
|
||||||
|
|
||||||
|
File natives = new File(getUserCache(), "natives/" + minecraftProvider.minecraftVersion());
|
||||||
|
|
||||||
|
if (!natives.exists()) {
|
||||||
|
natives.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
return natives;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getDefaultLog4jConfigFile() {
|
||||||
|
return new File(getProjectPersistentCache(), "log4j.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getDevLauncherConfig() {
|
||||||
|
return new File(getProjectPersistentCache(), "launch.cfg");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getUnpickLoggingConfigFile() {
|
||||||
|
return new File(getProjectPersistentCache(), "unpick-logging.properties");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,182 @@
|
||||||
|
/*
|
||||||
|
* 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 java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.gradle.api.Action;
|
||||||
|
import org.gradle.api.NamedDomainObjectContainer;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.artifacts.Dependency;
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection;
|
||||||
|
import org.gradle.api.plugins.BasePluginConvention;
|
||||||
|
|
||||||
|
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
|
||||||
|
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
|
||||||
|
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
||||||
|
import net.fabricmc.loom.configuration.processors.JarProcessor;
|
||||||
|
import net.fabricmc.loom.configuration.providers.mappings.GradleMappingContext;
|
||||||
|
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec;
|
||||||
|
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilder;
|
||||||
|
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingsDependency;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the public extension api.
|
||||||
|
*/
|
||||||
|
public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionAPI {
|
||||||
|
protected final List<LoomDecompiler> decompilers = new ArrayList<>();
|
||||||
|
protected final List<JarProcessor> jarProcessors = new ArrayList<>();
|
||||||
|
protected final ConfigurableFileCollection log4jConfigs;
|
||||||
|
|
||||||
|
protected File accessWidener = null;
|
||||||
|
protected boolean shareCaches = false;
|
||||||
|
protected String refmapName = null;
|
||||||
|
protected boolean remapMod = true;
|
||||||
|
|
||||||
|
private NamedDomainObjectContainer<RunConfigSettings> runConfigs;
|
||||||
|
|
||||||
|
protected LoomGradleExtensionApiImpl(Project project, LoomFiles directories) {
|
||||||
|
this.runConfigs = project.container(RunConfigSettings.class,
|
||||||
|
baseName -> new RunConfigSettings(project, baseName));
|
||||||
|
this.log4jConfigs = project.files(directories.getDefaultLog4jConfigFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File getAccessWidener() {
|
||||||
|
return accessWidener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAccessWidener(Object file) {
|
||||||
|
Objects.requireNonNull(file, "Access widener file cannot be null");
|
||||||
|
this.accessWidener = getProject().file(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setShareCaches(boolean shareCaches) {
|
||||||
|
this.shareCaches = shareCaches;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isShareCaches() {
|
||||||
|
return shareCaches;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<LoomDecompiler> getDecompilers() {
|
||||||
|
return decompilers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDecompiler(LoomDecompiler decompiler) {
|
||||||
|
Objects.requireNonNull(decompiler, "Decompiler cannot be null");
|
||||||
|
decompilers.add(decompiler);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<JarProcessor> getJarProcessors() {
|
||||||
|
return jarProcessors;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addJarProcessor(JarProcessor processor) {
|
||||||
|
Objects.requireNonNull(processor, "Jar processor cannot be null");
|
||||||
|
jarProcessors.add(processor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dependency layered(Action<LayeredMappingSpecBuilder> action) {
|
||||||
|
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder();
|
||||||
|
action.execute(builder);
|
||||||
|
LayeredMappingSpec builtSpec = builder.build();
|
||||||
|
return new LayeredMappingsDependency(new GradleMappingContext(getProject(), "layers_" + builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRefmapName() {
|
||||||
|
if (refmapName == null || refmapName.isEmpty()) {
|
||||||
|
String defaultRefmapName = getProject().getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-refmap.json";
|
||||||
|
getProject().getLogger().info("Could not find refmap definition, will be using default name: " + defaultRefmapName);
|
||||||
|
refmapName = defaultRefmapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return refmapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRefmapName(String refmapName) {
|
||||||
|
this.refmapName = refmapName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRemapMod(boolean remapMod) {
|
||||||
|
this.remapMod = remapMod;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runs(Action<NamedDomainObjectContainer<RunConfigSettings>> action) {
|
||||||
|
action.execute(runConfigs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NamedDomainObjectContainer<RunConfigSettings> getRunConfigs() {
|
||||||
|
return runConfigs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigurableFileCollection getLog4jConfigs() {
|
||||||
|
return log4jConfigs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRemapMod() {
|
||||||
|
return remapMod;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Project getProject();
|
||||||
|
|
||||||
|
protected abstract LoomFiles getFiles();
|
||||||
|
|
||||||
|
// This is here to ensure that LoomGradleExtensionApiImpl compiles without any unimplemented methods
|
||||||
|
private final class EnsureCompile extends LoomGradleExtensionApiImpl {
|
||||||
|
private EnsureCompile() {
|
||||||
|
super(null, null);
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Project getProject() {
|
||||||
|
throw new RuntimeException("Yeah... something is really wrong");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected LoomFiles getFiles() {
|
||||||
|
throw new RuntimeException("Yeah... something is really wrong");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
/*
|
||||||
|
* 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 java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.cadixdev.lorenz.MappingSet;
|
||||||
|
import org.cadixdev.mercury.Mercury;
|
||||||
|
import org.gradle.api.NamedDomainObjectProvider;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.artifacts.Configuration;
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection;
|
||||||
|
|
||||||
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
|
import net.fabricmc.loom.configuration.InstallerData;
|
||||||
|
import net.fabricmc.loom.configuration.LoomDependencyManager;
|
||||||
|
import net.fabricmc.loom.configuration.processors.JarProcessorManager;
|
||||||
|
|
||||||
|
public class LoomGradleExtensionImpl extends LoomGradleExtensionApiImpl implements LoomGradleExtension {
|
||||||
|
private final Project project;
|
||||||
|
private final LoomFiles loomFiles;
|
||||||
|
private final ConfigurableFileCollection unmappedMods;
|
||||||
|
|
||||||
|
private final Set<File> mixinMappings = Collections.synchronizedSet(new HashSet<>());
|
||||||
|
private final MappingSet[] srcMappingCache = new MappingSet[2];
|
||||||
|
private final Mercury[] srcMercuryCache = new Mercury[2];
|
||||||
|
private final Map<String, NamedDomainObjectProvider<Configuration>> lazyConfigurations = new HashMap<>();
|
||||||
|
|
||||||
|
private LoomDependencyManager dependencyManager;
|
||||||
|
private JarProcessorManager jarProcessorManager;
|
||||||
|
private InstallerData installerData;
|
||||||
|
|
||||||
|
public LoomGradleExtensionImpl(Project project, LoomFiles files) {
|
||||||
|
super(project, files);
|
||||||
|
this.project = project;
|
||||||
|
this.loomFiles = files;
|
||||||
|
this.unmappedMods = project.files();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Project getProject() {
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoomFiles getFiles() {
|
||||||
|
return loomFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized File getNextMixinMappings() {
|
||||||
|
File mixinMapping = new File(getFiles().getProjectBuildCache(), "mixin-map-" + getMinecraftProvider().minecraftVersion() + "-" + getMappingsProvider().mappingsVersion + "." + mixinMappings.size() + ".tiny");
|
||||||
|
mixinMappings.add(mixinMapping);
|
||||||
|
return mixinMapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<File> getAllMixinMappings() {
|
||||||
|
return mixinMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDependencyManager(LoomDependencyManager dependencyManager) {
|
||||||
|
this.dependencyManager = dependencyManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoomDependencyManager getDependencyManager() {
|
||||||
|
return Objects.requireNonNull(dependencyManager, "Cannot get LoomDependencyManager before it has been setup");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJarProcessorManager(JarProcessorManager jarProcessorManager) {
|
||||||
|
this.jarProcessorManager = jarProcessorManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JarProcessorManager getJarProcessorManager() {
|
||||||
|
return Objects.requireNonNull(jarProcessorManager, "Cannot get JarProcessorManager before it has been setup");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MappingSet getOrCreateSrcMappingCache(int id, Supplier<MappingSet> factory) {
|
||||||
|
return srcMappingCache[id] != null ? srcMappingCache[id] : (srcMappingCache[id] = factory.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mercury getOrCreateSrcMercuryCache(int id, Supplier<Mercury> factory) {
|
||||||
|
return srcMercuryCache[id] != null ? srcMercuryCache[id] : (srcMercuryCache[id] = factory.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigurableFileCollection getUnmappedModCollection() {
|
||||||
|
return unmappedMods;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstallerData(InstallerData object) {
|
||||||
|
this.installerData = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstallerData getInstallerData() {
|
||||||
|
return installerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isRootProject() {
|
||||||
|
return project.getRootProject() == project;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NamedDomainObjectProvider<Configuration> createLazyConfiguration(String name) {
|
||||||
|
NamedDomainObjectProvider<Configuration> provider = project.getConfigurations().register(name);
|
||||||
|
|
||||||
|
if (lazyConfigurations.containsKey(name)) {
|
||||||
|
throw new IllegalStateException("Duplicate configuration name" + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
lazyConfigurations.put(name, provider);
|
||||||
|
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NamedDomainObjectProvider<Configuration> getLazyConfigurationProvider(String name) {
|
||||||
|
NamedDomainObjectProvider<Configuration> provider = lazyConfigurations.get(name);
|
||||||
|
|
||||||
|
if (provider == null) {
|
||||||
|
throw new NullPointerException("Could not find provider with name: " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,6 +36,6 @@ public abstract class AbstractLoomTask extends DefaultTask {
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
protected LoomGradleExtension getExtension() {
|
protected LoomGradleExtension getExtension() {
|
||||||
return getProject().getExtensions().getByType(LoomGradleExtension.class);
|
return LoomGradleExtension.get(getProject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class GenerateSourcesTask extends AbstractLoomTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getMappedJarFileWithSuffix(String suffix) {
|
private File getMappedJarFileWithSuffix(String suffix) {
|
||||||
LoomGradleExtension extension = getProject().getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(getProject());
|
||||||
MappingsProviderImpl mappingsProvider = extension.getMappingsProvider();
|
MappingsProviderImpl mappingsProvider = extension.getMappingsProvider();
|
||||||
File mappedJar = mappingsProvider.mappedProvider.getMappedJar();
|
File mappedJar = mappingsProvider.mappedProvider.getMappedJar();
|
||||||
String path = mappedJar.getAbsolutePath();
|
String path = mappedJar.getAbsolutePath();
|
||||||
|
|
|
@ -87,7 +87,7 @@ public final class LoomTasks {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerRunTasks(TaskContainer tasks, Project project) {
|
private static void registerRunTasks(TaskContainer tasks, Project project) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
Preconditions.checkArgument(extension.getRunConfigs().size() == 0, "Run configurations must not be registered before loom");
|
Preconditions.checkArgument(extension.getRunConfigs().size() == 0, "Run configurations must not be registered before loom");
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public final class LoomTasks {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerDecompileTasks(TaskContainer tasks, Project project) {
|
private static void registerDecompileTasks(TaskContainer tasks, Project project) {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
|
|
||||||
project.afterEvaluate(p -> {
|
project.afterEvaluate(p -> {
|
||||||
MappingsProviderImpl mappingsProvider = extension.getMappingsProvider();
|
MappingsProviderImpl mappingsProvider = extension.getMappingsProvider();
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class MigrateMappingsTask extends AbstractLoomTask {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mappings.startsWith("net.minecraft:mappings:") || mappings.startsWith("net.mojang.minecraft:mappings:")) {
|
if (mappings.startsWith("net.minecraft:mappings:") || mappings.startsWith("net.mojang.minecraft:mappings:")) {
|
||||||
if (!mappings.endsWith(":" + project.getExtensions().getByType(LoomGradleExtension.class).getMinecraftProvider().minecraftVersion())) {
|
if (!mappings.endsWith(":" + LoomGradleExtension.get(project).getMinecraftProvider().minecraftVersion())) {
|
||||||
throw new UnsupportedOperationException("Migrating Mojang mappings is currently only supported for the specified minecraft version");
|
throw new UnsupportedOperationException("Migrating Mojang mappings is currently only supported for the specified minecraft version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class RemapJarTask extends Jar {
|
||||||
jarRemapper = new JarRemapper();
|
jarRemapper = new JarRemapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduleRemap(singleRemap || getProject().getExtensions().getByType(LoomGradleExtension.class).isRootProject());
|
scheduleRemap(singleRemap || LoomGradleExtension.get(getProject()).isRootProject());
|
||||||
|
|
||||||
if (singleRemap) {
|
if (singleRemap) {
|
||||||
jarRemapper.remap();
|
jarRemapper.remap();
|
||||||
|
@ -114,7 +114,7 @@ public class RemapJarTask extends Jar {
|
||||||
|
|
||||||
public void scheduleRemap(boolean isMainRemapTask) throws Throwable {
|
public void scheduleRemap(boolean isMainRemapTask) throws Throwable {
|
||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(getProject());
|
||||||
Path input = this.getInput().getAsFile().get().toPath();
|
Path input = this.getInput().getAsFile().get().toPath();
|
||||||
Path output = this.getArchivePath().toPath();
|
Path output = this.getArchivePath().toPath();
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public class RemapJarTask extends Jar {
|
||||||
|
|
||||||
jarRemapper.scheduleRemap(input, output)
|
jarRemapper.scheduleRemap(input, output)
|
||||||
.supplyAccessWidener((remapData, remapper) -> {
|
.supplyAccessWidener((remapData, remapper) -> {
|
||||||
if (getRemapAccessWidener().getOrElse(false) && extension.accessWidener != null) {
|
if (getRemapAccessWidener().getOrElse(false) && extension.getAccessWidener() != null) {
|
||||||
AccessWidenerJarProcessor accessWidenerJarProcessor = extension.getJarProcessorManager().getByType(AccessWidenerJarProcessor.class);
|
AccessWidenerJarProcessor accessWidenerJarProcessor = extension.getJarProcessorManager().getByType(AccessWidenerJarProcessor.class);
|
||||||
byte[] data;
|
byte[] data;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import net.fabricmc.loom.configuration.ide.RunConfig;
|
||||||
public class RunClientTask extends AbstractRunTask {
|
public class RunClientTask extends AbstractRunTask {
|
||||||
public RunClientTask() {
|
public RunClientTask() {
|
||||||
super(project -> {
|
super(project -> {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
return RunConfig.runConfig(project, extension.getRunConfigs().getByName("client"));
|
return RunConfig.runConfig(project, extension.getRunConfigs().getByName("client"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import net.fabricmc.loom.configuration.ide.RunConfig;
|
||||||
public class RunServerTask extends AbstractRunTask {
|
public class RunServerTask extends AbstractRunTask {
|
||||||
public RunServerTask() {
|
public RunServerTask() {
|
||||||
super(project -> {
|
super(project -> {
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
return RunConfig.runConfig(project, extension.getRunConfigs().getByName("client"));
|
return RunConfig.runConfig(project, extension.getRunConfigs().getByName("client"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.gradle.api.tasks.OutputFile;
|
||||||
|
|
||||||
import net.fabricmc.loom.LoomGradleExtension;
|
import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.configuration.providers.LaunchProvider;
|
import net.fabricmc.loom.configuration.providers.LaunchProvider;
|
||||||
|
import net.fabricmc.loom.extension.LoomFiles;
|
||||||
import net.fabricmc.loom.util.Constants;
|
import net.fabricmc.loom.util.Constants;
|
||||||
|
|
||||||
public class UnpickJarTask extends JavaExec {
|
public class UnpickJarTask extends JavaExec {
|
||||||
|
@ -60,15 +61,15 @@ public class UnpickJarTask extends JavaExec {
|
||||||
fileArg(getMinecraftDependencies());
|
fileArg(getMinecraftDependencies());
|
||||||
|
|
||||||
writeUnpickLogConfig();
|
writeUnpickLogConfig();
|
||||||
systemProperty("java.util.logging.config.file", getExtension().getUnpickLoggingConfigFile().getAbsolutePath());
|
systemProperty("java.util.logging.config.file", getDirectories().getUnpickLoggingConfigFile().getAbsolutePath());
|
||||||
|
|
||||||
super.exec();
|
super.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeUnpickLogConfig() {
|
private void writeUnpickLogConfig() {
|
||||||
try (InputStream is = LaunchProvider.class.getClassLoader().getResourceAsStream("unpick-logging.properties")) {
|
try (InputStream is = LaunchProvider.class.getClassLoader().getResourceAsStream("unpick-logging.properties")) {
|
||||||
Files.deleteIfExists(getExtension().getUnpickLoggingConfigFile().toPath());
|
Files.deleteIfExists(getDirectories().getUnpickLoggingConfigFile().toPath());
|
||||||
Files.copy(is, getExtension().getUnpickLoggingConfigFile().toPath());
|
Files.copy(is, getDirectories().getUnpickLoggingConfigFile().toPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to copy unpick logging config", e);
|
throw new RuntimeException("Failed to copy unpick logging config", e);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +122,10 @@ public class UnpickJarTask extends JavaExec {
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
protected LoomGradleExtension getExtension() {
|
protected LoomGradleExtension getExtension() {
|
||||||
return getProject().getExtensions().getByType(LoomGradleExtension.class);
|
return LoomGradleExtension.get(getProject());
|
||||||
|
}
|
||||||
|
|
||||||
|
private LoomFiles getDirectories() {
|
||||||
|
return getExtension().getFiles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,14 +109,6 @@ public class Constants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class LaunchWrapper {
|
|
||||||
public static final String DEFAULT_FABRIC_CLIENT_TWEAKER = "net.fabricmc.loader.launch.FabricClientTweaker";
|
|
||||||
public static final String DEFAULT_FABRIC_SERVER_TWEAKER = "net.fabricmc.loader.launch.FabricServerTweaker";
|
|
||||||
|
|
||||||
private LaunchWrapper() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class Knot {
|
public static final class Knot {
|
||||||
public static final String KNOT_CLIENT = "net.fabricmc.loader.launch.knot.KnotClient";
|
public static final String KNOT_CLIENT = "net.fabricmc.loader.launch.knot.KnotClient";
|
||||||
public static final String KNOT_SERVER = "net.fabricmc.loader.launch.knot.KnotServer";
|
public static final String KNOT_SERVER = "net.fabricmc.loader.launch.knot.KnotServer";
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class SourceRemapper {
|
||||||
return this.mercury;
|
return this.mercury;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
|
LoomGradleExtension extension = LoomGradleExtension.get(project);
|
||||||
MappingsProviderImpl mappingsProvider = extension.getMappingsProvider();
|
MappingsProviderImpl mappingsProvider = extension.getMappingsProvider();
|
||||||
|
|
||||||
MappingSet mappings = extension.getOrCreateSrcMappingCache(toNamed ? 1 : 0, () -> {
|
MappingSet mappings = extension.getOrCreateSrcMappingCache(toNamed ? 1 : 0, () -> {
|
||||||
|
|
Loading…
Reference in New Issue