mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
@@ -27,7 +27,6 @@ package net.fabricmc.loom.api;
|
||||
import java.util.List;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.provider.SetProperty;
|
||||
@@ -133,25 +132,4 @@ public interface ForgeExtensionAPI {
|
||||
*/
|
||||
void mod(String... modIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures local mods.
|
||||
*
|
||||
* @param action the configuration action
|
||||
* @deprecated Replaced with {@link LoomGradleExtensionAPI#mods(Action)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "0.12.0")
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "1.0")
|
||||
void localMods(Action<NamedDomainObjectContainer<ForgeLocalMod>> action);
|
||||
|
||||
/**
|
||||
* The container of local mods applied to run configs.
|
||||
*
|
||||
* @return the container
|
||||
* @see ForgeLocalMod
|
||||
* @deprecated Replaced with {@link LoomGradleExtensionAPI#getMods()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "0.12.0")
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "1.0")
|
||||
NamedDomainObjectContainer<ForgeLocalMod> getLocalMods();
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* 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.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.gradle.api.Named;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
import org.gradle.api.tasks.SourceSet;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Data for a mod built from project files in a dev environment.
|
||||
* This data is only used for run config generation (FML needs the paths to mod files).
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "0.12.0")
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "1.0")
|
||||
public class ForgeLocalMod implements Named {
|
||||
private final Project project;
|
||||
private final String name;
|
||||
private final List<Supplier<SourceSet>> sourceSets;
|
||||
|
||||
/**
|
||||
* Constructs a local mod.
|
||||
*
|
||||
* @param project the project using this mod
|
||||
* @param name the unique name of this local mod (does not have to correspond to a mod ID)
|
||||
* @param sourceSets the list of source set suppliers corresponding to this mod; must be mutable
|
||||
*/
|
||||
public ForgeLocalMod(Project project, String name, List<Supplier<SourceSet>> sourceSets) {
|
||||
this.project = project;
|
||||
this.name = name;
|
||||
this.sourceSets = sourceSets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds source sets to this local mod.
|
||||
*
|
||||
* <p>The source sets are resolved like this:
|
||||
* <ul>
|
||||
* <li>a {@link SourceSet} is used as is</li>
|
||||
* <li>all other objects will be converted to source set names with {@link String#valueOf(Object)} and
|
||||
* fetched with {@code sourceSets.findByName(name)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param sourceSets the source sets
|
||||
*/
|
||||
public void add(Object... sourceSets) {
|
||||
for (Object sourceSet : sourceSets) {
|
||||
if (sourceSet instanceof SourceSet) {
|
||||
this.sourceSets.add(() -> (SourceSet) sourceSet);
|
||||
} else {
|
||||
this.sourceSets.add(() -> project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName(String.valueOf(sourceSet)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Stream<SourceSet> getSourceSets() {
|
||||
return sourceSets.stream().map(Supplier::get);
|
||||
}
|
||||
}
|
||||
@@ -261,6 +261,14 @@ public final class CompileConfiguration {
|
||||
p.getTasks().withType(AbstractCopyTask.class).configureEach(abstractCopyTask -> abstractCopyTask.setFilteringCharset(StandardCharsets.UTF_8.name()));
|
||||
p.getTasks().withType(JavaCompile.class).configureEach(javaCompile -> javaCompile.getOptions().setEncoding(StandardCharsets.UTF_8.name()));
|
||||
|
||||
if (extension.isForge()) {
|
||||
// Create default mod from main source set
|
||||
extension.mods(mods -> {
|
||||
final SourceSet main = javaPluginExtension.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
|
||||
mods.create("main").sourceSet(main);
|
||||
});
|
||||
}
|
||||
|
||||
if (p.getPluginManager().hasPlugin("org.jetbrains.kotlin.kapt")) {
|
||||
// If loom is applied after kapt, then kapt will use the AP arguments too early for loom to pass the arguments we need for mixin.
|
||||
throw new IllegalArgumentException("fabric-loom must be applied BEFORE kapt in the plugins { } block.");
|
||||
|
||||
@@ -42,7 +42,6 @@ import com.google.gson.JsonObject;
|
||||
import org.gradle.api.Project;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.api.ForgeLocalMod;
|
||||
import net.fabricmc.loom.api.ModSettings;
|
||||
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
||||
import net.fabricmc.loom.configuration.launch.LaunchProviderSettings;
|
||||
@@ -160,8 +159,6 @@ public class ForgeRunsProvider {
|
||||
string = extension.getFiles().getNativesDirectory(project).getAbsolutePath();
|
||||
} else if (key.equals("source_roots")) {
|
||||
// Use a set-valued multimap for deduplicating paths.
|
||||
// It could be done using Stream.distinct before but that doesn't work if
|
||||
// you have *both* a ModSettings and a ForgeLocalMod with the same name.
|
||||
Multimap<String, String> modClasses = MultimapBuilder.hashKeys().linkedHashSetValues().build();
|
||||
|
||||
for (ModSettings mod : extension.getMods()) {
|
||||
@@ -170,15 +167,6 @@ public class ForgeRunsProvider {
|
||||
}
|
||||
}
|
||||
|
||||
for (ForgeLocalMod localMod : extension.getForge().getLocalMods()) {
|
||||
String sourceSetName = localMod.getName();
|
||||
|
||||
localMod.getSourceSets().flatMap(sourceSet -> Stream.concat(
|
||||
Stream.of(sourceSet.getOutput().getResourcesDir()),
|
||||
sourceSet.getOutput().getClassesDirs().getFiles().stream())
|
||||
).map(File::getAbsolutePath).forEach(path -> modClasses.put(sourceSetName, path));
|
||||
}
|
||||
|
||||
string = modClasses.entries().stream()
|
||||
.map(entry -> entry.getKey() + "%%" + entry.getValue())
|
||||
.collect(Collectors.joining(File.pathSeparator));
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.NamedDomainObjectContainer;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.file.ConfigurableFileCollection;
|
||||
import org.gradle.api.provider.Property;
|
||||
@@ -40,7 +39,6 @@ import org.gradle.api.provider.SetProperty;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.api.ForgeExtensionAPI;
|
||||
import net.fabricmc.loom.api.ForgeLocalMod;
|
||||
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
||||
|
||||
public class ForgeExtensionImpl implements ForgeExtensionAPI {
|
||||
@@ -51,7 +49,6 @@ public class ForgeExtensionImpl implements ForgeExtensionAPI {
|
||||
private final SetProperty<String> mixinConfigs;
|
||||
private final Property<Boolean> useCustomMixin;
|
||||
private final List<String> dataGenMods = new ArrayList<>(); // not a property because it has custom adding logic
|
||||
private final NamedDomainObjectContainer<ForgeLocalMod> localMods;
|
||||
|
||||
@Inject
|
||||
public ForgeExtensionImpl(Project project, LoomGradleExtension extension) {
|
||||
@@ -61,11 +58,6 @@ public class ForgeExtensionImpl implements ForgeExtensionAPI {
|
||||
accessTransformers = project.getObjects().fileCollection();
|
||||
mixinConfigs = project.getObjects().setProperty(String.class).empty();
|
||||
useCustomMixin = project.getObjects().property(Boolean.class).convention(true);
|
||||
localMods = project.container(ForgeLocalMod.class,
|
||||
baseName -> new ForgeLocalMod(project, baseName, new ArrayList<>()));
|
||||
|
||||
// Create default mod from main source set
|
||||
localMods(mod -> mod.create("main").add("main"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,16 +115,4 @@ public class ForgeExtensionImpl implements ForgeExtensionAPI {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void localMods(Action<NamedDomainObjectContainer<ForgeLocalMod>> action) {
|
||||
extension.getDeprecationHelper().toBeRemovedIn("loom.forge.localMods", "loom.mods", "1.0");
|
||||
action.execute(localMods);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedDomainObjectContainer<ForgeLocalMod> getLocalMods() {
|
||||
extension.getDeprecationHelper().toBeRemovedIn("loom.forge.localMods", "loom.mods", "1.0");
|
||||
return localMods;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user