2016-08-16 22:29:10 +00:00
|
|
|
/*
|
|
|
|
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
|
|
|
*
|
2018-10-27 14:14:05 +00:00
|
|
|
* Copyright (c) 2016, 2017, 2018 FabricMC
|
2016-08-16 22:29:10 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-08-16 23:30:48 +00:00
|
|
|
package net.fabricmc.loom;
|
2016-08-15 10:22:14 +00:00
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
import java.io.File;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
2020-09-06 19:21:08 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.HashSet;
|
2019-11-02 20:23:27 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Objects;
|
2020-09-06 19:21:08 +00:00
|
|
|
import java.util.Set;
|
2019-11-02 20:23:27 +00:00
|
|
|
import java.util.function.BiPredicate;
|
|
|
|
import java.util.function.Function;
|
|
|
|
import java.util.function.Supplier;
|
2020-06-29 14:25:05 +00:00
|
|
|
import java.util.stream.Collectors;
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2018-12-22 09:31:10 +00:00
|
|
|
import com.google.gson.JsonObject;
|
2018-12-22 13:37:16 +00:00
|
|
|
import org.cadixdev.lorenz.MappingSet;
|
2019-05-28 07:23:19 +00:00
|
|
|
import org.cadixdev.mercury.Mercury;
|
2016-08-25 11:42:23 +00:00
|
|
|
import org.gradle.api.Project;
|
2018-12-30 11:03:25 +00:00
|
|
|
import org.gradle.api.artifacts.Configuration;
|
2018-12-15 13:33:25 +00:00
|
|
|
import org.gradle.api.artifacts.Dependency;
|
2020-06-29 14:25:05 +00:00
|
|
|
import org.gradle.api.file.ConfigurableFileCollection;
|
2019-12-29 17:29:19 +00:00
|
|
|
import org.gradle.api.plugins.BasePluginConvention;
|
2020-12-24 20:58:30 +00:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2016-08-25 11:42:23 +00:00
|
|
|
|
2020-06-01 18:31:32 +00:00
|
|
|
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
|
2020-12-24 20:58:30 +00:00
|
|
|
import net.fabricmc.loom.configuration.LoomDependencyManager;
|
|
|
|
import net.fabricmc.loom.configuration.processors.JarProcessor;
|
|
|
|
import net.fabricmc.loom.configuration.processors.JarProcessorManager;
|
|
|
|
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
|
|
|
import net.fabricmc.loom.configuration.providers.mappings.MappingsProvider;
|
|
|
|
import net.fabricmc.loom.configuration.providers.mappings.MojangMappingsDependency;
|
|
|
|
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMappedProvider;
|
2016-08-25 11:42:23 +00:00
|
|
|
|
2016-08-16 18:19:05 +00:00
|
|
|
public class LoomGradleExtension {
|
2016-08-17 16:38:54 +00:00
|
|
|
public String runDir = "run";
|
2018-10-22 18:46:42 +00:00
|
|
|
public String refmapName;
|
2018-12-22 09:31:10 +00:00
|
|
|
public String loaderLaunchMethod;
|
2018-11-05 20:33:57 +00:00
|
|
|
public boolean remapMod = true;
|
2020-07-26 20:05:14 +00:00
|
|
|
public boolean autoGenIDERuns;
|
2019-08-15 16:45:08 +00:00
|
|
|
public String customManifest = null;
|
0.2.7 refactors (#178)
* Rough work on project based jars, skeleton for AccessEscalators?
* First working draft
* Minor changes
* Add support for mutable, better error checking when parsing file.
Code cleanup
Remap if needed when reading
* Fix inner classes and genSources
* Fix CME
* Caching, only regen jar when input changes
* Some work, untested
* Fix writing, fix checkstyle issues
* More fixes
* Move jars into a maven file structure, cleans up the file structure, and will benefit idea 2020
Add some basic validation to the AccessWidenerRemapper, will present any issues with the mappings when building (May need a way to disable?)
+ Some bugs fixes
* Fix issues with source jars in idea 2020, should be backwards compatible with 2019
* Move to lorenz-tiny
* Build fix + small cleanup
* Remove accesswidener's for now
* Update dev launch injector, should fix all issues with spaces in the path.
2020-03-06 11:15:34 +00:00
|
|
|
public File accessWidener = null;
|
2020-03-26 19:40:00 +00:00
|
|
|
public Function<String, Object> intermediaryUrl = mcVer -> "https://maven.fabricmc.net/net/fabricmc/intermediary/" + mcVer + "/intermediary-" + mcVer + "-v2.jar";
|
2020-06-27 19:18:32 +00:00
|
|
|
public boolean shareCaches = false;
|
2016-08-25 11:42:23 +00:00
|
|
|
|
2020-06-29 14:25:05 +00:00
|
|
|
private final ConfigurableFileCollection unmappedMods;
|
2018-12-12 06:10:30 +00:00
|
|
|
|
2020-06-01 18:31:32 +00:00
|
|
|
final List<LoomDecompiler> decompilers = new ArrayList<>();
|
2020-08-24 19:10:21 +00:00
|
|
|
private final List<JarProcessor> jarProcessors = new ArrayList<>();
|
2020-06-01 18:31:32 +00:00
|
|
|
|
2020-07-26 20:32:10 +00:00
|
|
|
// Not to be set in the build.gradle
|
2020-06-29 14:25:05 +00:00
|
|
|
private final Project project;
|
2018-11-04 21:28:46 +00:00
|
|
|
private LoomDependencyManager dependencyManager;
|
0.2.7 refactors (#178)
* Rough work on project based jars, skeleton for AccessEscalators?
* First working draft
* Minor changes
* Add support for mutable, better error checking when parsing file.
Code cleanup
Remap if needed when reading
* Fix inner classes and genSources
* Fix CME
* Caching, only regen jar when input changes
* Some work, untested
* Fix writing, fix checkstyle issues
* More fixes
* Move jars into a maven file structure, cleans up the file structure, and will benefit idea 2020
Add some basic validation to the AccessWidenerRemapper, will present any issues with the mappings when building (May need a way to disable?)
+ Some bugs fixes
* Fix issues with source jars in idea 2020, should be backwards compatible with 2019
* Move to lorenz-tiny
* Build fix + small cleanup
* Remove accesswidener's for now
* Update dev launch injector, should fix all issues with spaces in the path.
2020-03-06 11:15:34 +00:00
|
|
|
private JarProcessorManager jarProcessorManager;
|
2018-12-22 09:31:10 +00:00
|
|
|
private JsonObject installerJson;
|
2018-12-22 13:37:16 +00:00
|
|
|
private MappingSet[] srcMappingCache = new MappingSet[2];
|
2019-05-28 07:23:19 +00:00
|
|
|
private Mercury[] srcMercuryCache = new Mercury[2];
|
2020-09-06 19:21:08 +00:00
|
|
|
private Set<File> mixinMappings = Collections.synchronizedSet(new HashSet<>());
|
2018-12-22 13:37:16 +00:00
|
|
|
|
2020-06-01 18:31:32 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2020-08-24 19:10:21 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2018-12-22 13:37:16 +00:00
|
|
|
public MappingSet getOrCreateSrcMappingCache(int id, Supplier<MappingSet> factory) {
|
|
|
|
return srcMappingCache[id] != null ? srcMappingCache[id] : (srcMappingCache[id] = factory.get());
|
|
|
|
}
|
2018-11-04 00:27:55 +00:00
|
|
|
|
2019-05-28 07:23:19 +00:00
|
|
|
public Mercury getOrCreateSrcMercuryCache(int id, Supplier<Mercury> factory) {
|
|
|
|
return srcMercuryCache[id] != null ? srcMercuryCache[id] : (srcMercuryCache[id] = factory.get());
|
|
|
|
}
|
|
|
|
|
2020-08-24 21:12:26 +00:00
|
|
|
public Dependency officialMojangMappings() {
|
|
|
|
return new MojangMappingsDependency(project, this);
|
|
|
|
}
|
|
|
|
|
2018-11-04 00:27:55 +00:00
|
|
|
public LoomGradleExtension(Project project) {
|
|
|
|
this.project = project;
|
2020-12-24 20:58:30 +00:00
|
|
|
this.autoGenIDERuns = isRootProject();
|
2020-06-29 14:25:05 +00:00
|
|
|
this.unmappedMods = project.files();
|
2018-11-04 00:27:55 +00:00
|
|
|
}
|
2016-08-25 11:42:23 +00:00
|
|
|
|
2020-06-29 14:25:05 +00:00
|
|
|
/**
|
|
|
|
* @see ConfigurableFileCollection#from(Object...)
|
|
|
|
* @deprecated use {@link #getUnmappedModCollection()}{@code .from()} instead
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2019-05-10 22:53:50 +00:00
|
|
|
public void addUnmappedMod(Path file) {
|
2020-06-29 14:25:05 +00:00
|
|
|
getUnmappedModCollection().from(file);
|
2018-12-12 06:10:30 +00:00
|
|
|
}
|
|
|
|
|
2020-06-29 14:25:05 +00:00
|
|
|
/**
|
|
|
|
* @deprecated use {@link #getUnmappedModCollection()} instead
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2019-05-10 22:53:50 +00:00
|
|
|
public List<Path> getUnmappedMods() {
|
2020-06-29 14:25:05 +00:00
|
|
|
return unmappedMods.getFiles().stream()
|
|
|
|
.map(File::toPath)
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
}
|
|
|
|
|
|
|
|
public ConfigurableFileCollection getUnmappedModCollection() {
|
|
|
|
return unmappedMods;
|
2018-12-12 06:10:30 +00:00
|
|
|
}
|
|
|
|
|
2019-11-12 18:46:57 +00:00
|
|
|
public void setInstallerJson(JsonObject object) {
|
|
|
|
this.installerJson = object;
|
2019-11-02 20:23:27 +00:00
|
|
|
}
|
2018-12-22 09:31:10 +00:00
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
public JsonObject getInstallerJson() {
|
|
|
|
return installerJson;
|
|
|
|
}
|
2018-12-22 09:31:10 +00:00
|
|
|
|
2020-05-11 11:48:04 +00:00
|
|
|
public void accessWidener(Object file) {
|
|
|
|
this.accessWidener = project.file(file);
|
|
|
|
}
|
|
|
|
|
2018-05-13 01:43:40 +00:00
|
|
|
public File getUserCache() {
|
2018-10-22 18:25:18 +00:00
|
|
|
File userCache = new File(project.getGradle().getGradleUserHomeDir(), "caches" + File.separator + "fabric-loom");
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2016-08-25 11:42:23 +00:00
|
|
|
if (!userCache.exists()) {
|
|
|
|
userCache.mkdirs();
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2016-08-25 11:42:23 +00:00
|
|
|
return userCache;
|
|
|
|
}
|
2017-02-09 18:21:42 +00:00
|
|
|
|
2019-04-21 12:39:51 +00:00
|
|
|
public File getRootProjectPersistentCache() {
|
2019-06-24 10:23:28 +00:00
|
|
|
File projectCache = new File(project.getRootProject().file(".gradle"), "loom-cache");
|
2019-11-02 20:23:27 +00:00
|
|
|
|
|
|
|
if (!projectCache.exists()) {
|
2019-04-21 12:39:51 +00:00
|
|
|
projectCache.mkdirs();
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-04-21 12:39:51 +00:00
|
|
|
return projectCache;
|
|
|
|
}
|
|
|
|
|
0.2.7 refactors (#178)
* Rough work on project based jars, skeleton for AccessEscalators?
* First working draft
* Minor changes
* Add support for mutable, better error checking when parsing file.
Code cleanup
Remap if needed when reading
* Fix inner classes and genSources
* Fix CME
* Caching, only regen jar when input changes
* Some work, untested
* Fix writing, fix checkstyle issues
* More fixes
* Move jars into a maven file structure, cleans up the file structure, and will benefit idea 2020
Add some basic validation to the AccessWidenerRemapper, will present any issues with the mappings when building (May need a way to disable?)
+ Some bugs fixes
* Fix issues with source jars in idea 2020, should be backwards compatible with 2019
* Move to lorenz-tiny
* Build fix + small cleanup
* Remove accesswidener's for now
* Update dev launch injector, should fix all issues with spaces in the path.
2020-03-06 11:15:34 +00:00
|
|
|
public File getProjectPersistentCache() {
|
|
|
|
File projectCache = new File(project.file(".gradle"), "loom-cache");
|
|
|
|
|
|
|
|
if (!projectCache.exists()) {
|
|
|
|
projectCache.mkdirs();
|
|
|
|
}
|
|
|
|
|
|
|
|
return projectCache;
|
|
|
|
}
|
|
|
|
|
2019-04-21 09:18:45 +00:00
|
|
|
public File getRootProjectBuildCache() {
|
|
|
|
File projectCache = new File(project.getRootProject().getBuildDir(), "loom-cache");
|
2019-11-02 20:23:27 +00:00
|
|
|
|
|
|
|
if (!projectCache.exists()) {
|
2019-04-21 09:18:45 +00:00
|
|
|
projectCache.mkdirs();
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-04-21 09:18:45 +00:00
|
|
|
return projectCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
public File getProjectBuildCache() {
|
|
|
|
File projectCache = new File(project.getBuildDir(), "loom-cache");
|
2019-11-02 20:23:27 +00:00
|
|
|
|
|
|
|
if (!projectCache.exists()) {
|
2018-12-10 14:28:58 +00:00
|
|
|
projectCache.mkdirs();
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2018-12-10 14:28:58 +00:00
|
|
|
return projectCache;
|
|
|
|
}
|
|
|
|
|
2018-12-22 13:44:34 +00:00
|
|
|
public File getRemappedModCache() {
|
2019-04-21 12:39:51 +00:00
|
|
|
File remappedModCache = new File(getRootProjectPersistentCache(), "remapped_mods");
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2018-12-22 13:44:34 +00:00
|
|
|
if (!remappedModCache.exists()) {
|
|
|
|
remappedModCache.mkdir();
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2018-12-22 13:44:34 +00:00
|
|
|
return remappedModCache;
|
|
|
|
}
|
|
|
|
|
2019-04-07 19:31:25 +00:00
|
|
|
public File getNestedModCache() {
|
2019-04-21 12:39:51 +00:00
|
|
|
File nestedModCache = new File(getRootProjectPersistentCache(), "nested_mods");
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-04-07 19:31:25 +00:00
|
|
|
if (!nestedModCache.exists()) {
|
|
|
|
nestedModCache.mkdir();
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-04-07 19:31:25 +00:00
|
|
|
return nestedModCache;
|
|
|
|
}
|
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
public File getNativesJarStore() {
|
2019-10-22 19:04:38 +00:00
|
|
|
File natives = new File(getUserCache(), "natives/jars");
|
2019-11-02 20:23:27 +00:00
|
|
|
|
|
|
|
if (!natives.exists()) {
|
2019-10-22 19:04:38 +00:00
|
|
|
natives.mkdirs();
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-10-22 19:04:38 +00:00
|
|
|
return natives;
|
|
|
|
}
|
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
public File getNativesDirectory() {
|
2020-12-27 16:25:30 +00:00
|
|
|
if (project.hasProperty("fabric.loom.natives.dir")) {
|
|
|
|
return new File((String) project.property("fabric.loom.natives.dir"));
|
2020-12-02 20:18:12 +00:00
|
|
|
}
|
|
|
|
|
0.2.7 refactors (#178)
* Rough work on project based jars, skeleton for AccessEscalators?
* First working draft
* Minor changes
* Add support for mutable, better error checking when parsing file.
Code cleanup
Remap if needed when reading
* Fix inner classes and genSources
* Fix CME
* Caching, only regen jar when input changes
* Some work, untested
* Fix writing, fix checkstyle issues
* More fixes
* Move jars into a maven file structure, cleans up the file structure, and will benefit idea 2020
Add some basic validation to the AccessWidenerRemapper, will present any issues with the mappings when building (May need a way to disable?)
+ Some bugs fixes
* Fix issues with source jars in idea 2020, should be backwards compatible with 2019
* Move to lorenz-tiny
* Build fix + small cleanup
* Remove accesswidener's for now
* Update dev launch injector, should fix all issues with spaces in the path.
2020-03-06 11:15:34 +00:00
|
|
|
File natives = new File(getUserCache(), "natives/" + getMinecraftProvider().getMinecraftVersion());
|
2019-11-02 20:23:27 +00:00
|
|
|
|
|
|
|
if (!natives.exists()) {
|
2019-10-22 19:04:38 +00:00
|
|
|
natives.mkdirs();
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-10-22 19:04:38 +00:00
|
|
|
return natives;
|
|
|
|
}
|
|
|
|
|
2020-12-02 20:18:12 +00:00
|
|
|
public boolean hasCustomNatives() {
|
|
|
|
return project.getProperties().get("fabric.loom.natives.dir") != null;
|
|
|
|
}
|
|
|
|
|
2019-11-11 18:52:19 +00:00
|
|
|
public File getDevLauncherConfig() {
|
2020-07-26 20:05:14 +00:00
|
|
|
return new File(getProjectPersistentCache(), "launch.cfg");
|
2019-11-11 18:52:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-15 13:33:25 +00:00
|
|
|
@Nullable
|
2019-05-27 20:14:35 +00:00
|
|
|
private static Dependency findDependency(Project p, Collection<Configuration> configs, BiPredicate<String, String> groupNameFilter) {
|
2019-04-27 20:31:50 +00:00
|
|
|
for (Configuration config : configs) {
|
2019-04-29 22:43:26 +00:00
|
|
|
for (Dependency dependency : config.getDependencies()) {
|
|
|
|
String group = dependency.getGroup();
|
|
|
|
String name = dependency.getName();
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-04-29 22:43:26 +00:00
|
|
|
if (groupNameFilter.test(group, name)) {
|
2019-05-27 20:14:35 +00:00
|
|
|
p.getLogger().debug("Loom findDependency found: " + group + ":" + name + ":" + dependency.getVersion());
|
2019-04-29 22:43:26 +00:00
|
|
|
return dependency;
|
2018-12-30 11:03:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
2019-04-29 22:43:26 +00:00
|
|
|
private <T> T recurseProjects(Function<Project, T> projectTFunction) {
|
|
|
|
Project p = this.project;
|
|
|
|
T result;
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2020-12-24 20:58:30 +00:00
|
|
|
while (!isRootProject()) {
|
2019-04-29 22:43:26 +00:00
|
|
|
if ((result = projectTFunction.apply(p)) != null) {
|
|
|
|
return result;
|
2019-04-15 08:12:48 +00:00
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-04-29 22:43:26 +00:00
|
|
|
p = p.getRootProject();
|
2019-04-14 18:08:26 +00:00
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-04-29 22:43:26 +00:00
|
|
|
result = projectTFunction.apply(p);
|
|
|
|
return result;
|
2018-12-30 11:03:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
2019-04-29 22:43:26 +00:00
|
|
|
private Dependency getMixinDependency() {
|
|
|
|
return recurseProjects((p) -> {
|
|
|
|
List<Configuration> configs = new ArrayList<>();
|
2019-05-27 20:14:35 +00:00
|
|
|
// check compile classpath first
|
2019-10-22 19:29:25 +00:00
|
|
|
Configuration possibleCompileClasspath = p.getConfigurations().findByName("compileClasspath");
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-10-22 19:29:25 +00:00
|
|
|
if (possibleCompileClasspath != null) {
|
|
|
|
configs.add(possibleCompileClasspath);
|
|
|
|
}
|
2019-11-02 20:23:27 +00:00
|
|
|
|
2019-04-29 22:43:26 +00:00
|
|
|
// failing that, buildscript
|
|
|
|
configs.addAll(p.getBuildscript().getConfigurations());
|
|
|
|
|
2019-05-27 20:14:35 +00:00
|
|
|
return findDependency(p, configs, (group, name) -> {
|
2019-04-29 22:43:26 +00:00
|
|
|
if (name.equalsIgnoreCase("mixin") && group.equalsIgnoreCase("org.spongepowered")) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-30 11:03:25 +00:00
|
|
|
|
2019-04-29 22:43:26 +00:00
|
|
|
if (name.equalsIgnoreCase("sponge-mixin") && group.equalsIgnoreCase("net.fabricmc")) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-30 11:03:25 +00:00
|
|
|
|
2019-04-29 22:43:26 +00:00
|
|
|
return false;
|
|
|
|
});
|
2018-12-30 11:03:25 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getMixinJsonVersion() {
|
2019-04-29 22:43:26 +00:00
|
|
|
Dependency dependency = getMixinDependency();
|
2018-12-30 11:03:25 +00:00
|
|
|
|
2019-04-29 22:43:26 +00:00
|
|
|
if (dependency != null) {
|
2018-12-30 11:03:25 +00:00
|
|
|
if (dependency.getGroup().equalsIgnoreCase("net.fabricmc")) {
|
2018-12-15 13:33:25 +00:00
|
|
|
if (Objects.requireNonNull(dependency.getVersion()).split("\\.").length >= 4) {
|
|
|
|
return dependency.getVersion().substring(0, dependency.getVersion().lastIndexOf('.')) + "-SNAPSHOT";
|
|
|
|
}
|
|
|
|
}
|
2018-12-30 11:03:25 +00:00
|
|
|
|
|
|
|
return dependency.getVersion();
|
2018-12-15 13:33:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-12-22 09:31:10 +00:00
|
|
|
public String getLoaderLaunchMethod() {
|
|
|
|
return loaderLaunchMethod != null ? loaderLaunchMethod : "";
|
|
|
|
}
|
|
|
|
|
2018-11-04 21:28:46 +00:00
|
|
|
public LoomDependencyManager getDependencyManager() {
|
|
|
|
return dependencyManager;
|
|
|
|
}
|
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
public MinecraftProvider getMinecraftProvider() {
|
2018-11-04 21:28:46 +00:00
|
|
|
return getDependencyManager().getProvider(MinecraftProvider.class);
|
|
|
|
}
|
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
public MinecraftMappedProvider getMinecraftMappedProvider() {
|
2018-12-09 21:22:35 +00:00
|
|
|
return getMappingsProvider().mappedProvider;
|
2018-11-21 08:03:56 +00:00
|
|
|
}
|
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
public MappingsProvider getMappingsProvider() {
|
2018-12-09 21:22:35 +00:00
|
|
|
return getDependencyManager().getProvider(MappingsProvider.class);
|
2018-11-05 15:54:14 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 21:28:46 +00:00
|
|
|
public void setDependencyManager(LoomDependencyManager dependencyManager) {
|
|
|
|
this.dependencyManager = dependencyManager;
|
2017-02-09 18:21:42 +00:00
|
|
|
}
|
2018-12-30 11:04:53 +00:00
|
|
|
|
0.2.7 refactors (#178)
* Rough work on project based jars, skeleton for AccessEscalators?
* First working draft
* Minor changes
* Add support for mutable, better error checking when parsing file.
Code cleanup
Remap if needed when reading
* Fix inner classes and genSources
* Fix CME
* Caching, only regen jar when input changes
* Some work, untested
* Fix writing, fix checkstyle issues
* More fixes
* Move jars into a maven file structure, cleans up the file structure, and will benefit idea 2020
Add some basic validation to the AccessWidenerRemapper, will present any issues with the mappings when building (May need a way to disable?)
+ Some bugs fixes
* Fix issues with source jars in idea 2020, should be backwards compatible with 2019
* Move to lorenz-tiny
* Build fix + small cleanup
* Remove accesswidener's for now
* Update dev launch injector, should fix all issues with spaces in the path.
2020-03-06 11:15:34 +00:00
|
|
|
public JarProcessorManager getJarProcessorManager() {
|
|
|
|
return jarProcessorManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setJarProcessorManager(JarProcessorManager jarProcessorManager) {
|
|
|
|
this.jarProcessorManager = jarProcessorManager;
|
|
|
|
}
|
|
|
|
|
2020-08-24 19:10:21 +00:00
|
|
|
public List<JarProcessor> getJarProcessors() {
|
|
|
|
return jarProcessors;
|
|
|
|
}
|
|
|
|
|
2018-12-30 11:04:53 +00:00
|
|
|
public String getRefmapName() {
|
2019-11-02 20:23:27 +00:00
|
|
|
if (refmapName == null || refmapName.isEmpty()) {
|
2019-12-29 17:29:19 +00:00
|
|
|
String defaultRefmapName = project.getConvention().getPlugin(BasePluginConvention.class).getArchivesBaseName() + "-refmap.json";
|
2020-05-22 13:38:25 +00:00
|
|
|
project.getLogger().info("Could not find refmap definition, will be using default name: " + defaultRefmapName);
|
2019-12-29 17:29:19 +00:00
|
|
|
refmapName = defaultRefmapName;
|
2018-12-30 11:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return refmapName;
|
|
|
|
}
|
2019-12-13 18:24:01 +00:00
|
|
|
|
|
|
|
public boolean ideSync() {
|
|
|
|
return Boolean.parseBoolean(System.getProperty("idea.sync.active", "false"));
|
|
|
|
}
|
2020-03-26 19:40:00 +00:00
|
|
|
|
|
|
|
// Ideally this should use maven, but this is a lot easier
|
|
|
|
public Function<String, String> getIntermediaryUrl() {
|
2020-07-26 20:32:10 +00:00
|
|
|
// Done like this to work around this possibly not being a java string...
|
2020-03-26 19:40:00 +00:00
|
|
|
return s -> intermediaryUrl.apply(s).toString();
|
|
|
|
}
|
2020-06-27 19:18:32 +00:00
|
|
|
|
|
|
|
public boolean isRootProject() {
|
|
|
|
return project.getRootProject() == project;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2020-09-04 21:41:11 +00:00
|
|
|
|
2020-09-06 19:21:08 +00:00
|
|
|
// 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().getMinecraftVersion() + "-" + getMappingsProvider().mappingsVersion + "." + mixinMappings.size() + ".tiny");
|
|
|
|
mixinMappings.add(mixinMapping);
|
|
|
|
return mixinMapping;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<File> getAllMixinMappings() {
|
|
|
|
return Collections.unmodifiableSet(mixinMappings);
|
2020-09-04 21:41:11 +00:00
|
|
|
}
|
2020-12-24 20:58:30 +00:00
|
|
|
|
|
|
|
public List<LoomDecompiler> getDecompilers() {
|
|
|
|
return decompilers;
|
|
|
|
}
|
2016-08-15 10:22:14 +00:00
|
|
|
}
|