mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 05:27:43 -05:00
Merge remote-tracking branch 'FabricMC/exp/0.10' into dev/future
# Conflicts: # bootstrap/test-project/build.gradle # build.gradle # src/main/java/net/fabricmc/loom/configuration/RemapConfiguration.java # src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java # src/main/java/net/fabricmc/loom/task/RemapSourcesJarTask.java
This commit is contained in:
@@ -45,8 +45,8 @@ import net.fabricmc.loom.configuration.MavenPublication;
|
||||
import net.fabricmc.loom.configuration.ide.IdeConfiguration;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsCache;
|
||||
import net.fabricmc.loom.decompilers.DecompilerConfiguration;
|
||||
import net.fabricmc.loom.extension.LoomFiles;
|
||||
import net.fabricmc.loom.extension.LoomGradleExtensionImpl;
|
||||
import net.fabricmc.loom.extension.LoomFilesImpl;
|
||||
import net.fabricmc.loom.extension.MinecraftGradleExtension;
|
||||
import net.fabricmc.loom.task.LoomTasks;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class LoomGradlePlugin implements BootstrappedPlugin {
|
||||
project.apply(ImmutableMap.of("plugin", "idea"));
|
||||
|
||||
// Setup extensions, minecraft wraps loom
|
||||
var extension = project.getExtensions().create(LoomGradleExtensionAPI.class, "loom", LoomGradleExtensionImpl.class, project, new LoomFilesImpl(project));
|
||||
var extension = project.getExtensions().create(LoomGradleExtensionAPI.class, "loom", LoomGradleExtensionImpl.class, project, LoomFiles.create(project));
|
||||
project.getExtensions().create(LoomGradleExtensionAPI.class, "minecraft", MinecraftGradleExtension.class, extension);
|
||||
project.getExtensions().create("fabricApi", FabricApiExtension.class, project);
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package net.fabricmc.loom;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.artifacts.dsl.RepositoryHandler;
|
||||
@@ -33,16 +31,17 @@ import org.gradle.api.artifacts.repositories.IvyArtifactRepository;
|
||||
import org.gradle.api.initialization.Settings;
|
||||
import org.gradle.api.invocation.Gradle;
|
||||
import org.gradle.api.plugins.PluginAware;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.fabricmc.loom.extension.LoomFiles;
|
||||
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
|
||||
public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||
@Override
|
||||
public void apply(PluginAware target) {
|
||||
RepositoryHandler repositories = null;
|
||||
|
||||
public void apply(@NotNull PluginAware target) {
|
||||
if (target instanceof Settings settings) {
|
||||
repositories = settings.getDependencyResolutionManagement().getRepositories();
|
||||
declareRepositories(settings.getDependencyResolutionManagement().getRepositories(), LoomFiles.create(settings));
|
||||
|
||||
// leave a marker so projects don't try to override these
|
||||
settings.getGradle().getPluginManager().apply(LoomRepositoryPlugin.class);
|
||||
@@ -51,23 +50,18 @@ public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||
return;
|
||||
}
|
||||
|
||||
repositories = project.getRepositories();
|
||||
declareRepositories(project.getRepositories(), LoomFiles.create(project));
|
||||
} else if (target instanceof Gradle) {
|
||||
return;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Expected target to be a Project or Settings, but was a " + target.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
Cache cache = new Cache(target);
|
||||
|
||||
// MavenConfiguration.java
|
||||
repositories.flatDir(repo -> {
|
||||
repo.setName("UserLocalCacheFiles");
|
||||
repo.dir(cache.getRootBuildCache());
|
||||
});
|
||||
private void declareRepositories(RepositoryHandler repositories, LoomFiles files) {
|
||||
repositories.maven(repo -> {
|
||||
repo.setName("UserLocalRemappedMods");
|
||||
repo.setUrl(cache.getRemappedModCache());
|
||||
repo.setUrl(files.getRemappedModCache());
|
||||
});
|
||||
repositories.maven(repo -> {
|
||||
repo.setName("Architectury");
|
||||
@@ -100,124 +94,16 @@ public class LoomRepositoryPlugin implements Plugin<PluginAware> {
|
||||
});
|
||||
repositories.mavenCentral();
|
||||
|
||||
// MinecraftMappedProvider.java
|
||||
repositories.ivy(repo -> {
|
||||
repo.setUrl(cache.getUserCache());
|
||||
repo.patternLayout(layout -> {
|
||||
layout.artifact("[revision]/[artifact]-[revision](-[classifier])(.[ext])");
|
||||
});
|
||||
repo.setUrl(files.getUserCache());
|
||||
repo.patternLayout(layout -> layout.artifact("[revision]/[artifact]-[revision](-[classifier])(.[ext])"));
|
||||
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
|
||||
});
|
||||
|
||||
// MinecraftProcessedProvider.java
|
||||
repositories.ivy(repo -> {
|
||||
repo.setUrl(cache.getRootPersistentCache());
|
||||
repo.patternLayout(layout -> {
|
||||
layout.artifact("[revision]/[artifact]-[revision](-[classifier])(.[ext])");
|
||||
});
|
||||
repo.setUrl(files.getRootProjectPersistentCache());
|
||||
repo.patternLayout(layout -> layout.artifact("[revision]/[artifact]-[revision](-[classifier])(.[ext])"));
|
||||
repo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
final class Cache {
|
||||
private PluginAware target;
|
||||
|
||||
Cache(PluginAware target) {
|
||||
if (target instanceof Project || target instanceof Settings) {
|
||||
this.target = target;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Expected target to be a Project or Settings, but was a " + target.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
File getUserCache() {
|
||||
File gradleUserHomeDir = null;
|
||||
|
||||
if (target instanceof Settings settings) {
|
||||
gradleUserHomeDir = settings.getGradle().getGradleUserHomeDir();
|
||||
} else if (target instanceof Project project) {
|
||||
gradleUserHomeDir = project.getGradle().getGradleUserHomeDir();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Expected target to be a Project or Settings, but was a " + target.getClass());
|
||||
}
|
||||
|
||||
File userCache = new File(gradleUserHomeDir, "caches" + File.separator + "fabric-loom");
|
||||
|
||||
if (!userCache.exists()) {
|
||||
userCache.mkdirs();
|
||||
}
|
||||
|
||||
return userCache;
|
||||
}
|
||||
|
||||
public File getRootPersistentCache() {
|
||||
File rootDir = null;
|
||||
|
||||
if (target instanceof Settings settings) {
|
||||
rootDir = settings.getRootDir();
|
||||
} else if (target instanceof Project project) {
|
||||
rootDir = project.getRootDir();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Expected target to be a Project or Settings, but was a " + target.getClass());
|
||||
}
|
||||
|
||||
File persistentCache = new File(rootDir, ".gradle" + File.separator + "loom-cache");
|
||||
|
||||
if (!persistentCache.exists()) {
|
||||
persistentCache.mkdirs();
|
||||
}
|
||||
|
||||
return persistentCache;
|
||||
}
|
||||
|
||||
public File getRootBuildCache() {
|
||||
File rootDir = null;
|
||||
|
||||
if (target instanceof Settings settings) {
|
||||
rootDir = settings.getRootDir();
|
||||
} else if (target instanceof Project project) {
|
||||
rootDir = project.getRootDir();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Expected target to be a Project or Settings, but was a " + target.getClass());
|
||||
}
|
||||
|
||||
File buildCache = new File(rootDir, "build" + File.separator + "loom-cache");
|
||||
|
||||
if (!buildCache.exists()) {
|
||||
buildCache.mkdirs();
|
||||
}
|
||||
|
||||
return buildCache;
|
||||
}
|
||||
|
||||
public File getRemappedModCache() {
|
||||
File remappedModCache = new File(getRootPersistentCache(), "remapped_mods");
|
||||
|
||||
if (!remappedModCache.exists()) {
|
||||
remappedModCache.mkdir();
|
||||
}
|
||||
|
||||
return remappedModCache;
|
||||
}
|
||||
|
||||
public File getNestedModCache() {
|
||||
File nestedModCache = new File(getRootPersistentCache(), "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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,11 @@ public class ModCompileRemapper {
|
||||
project.getLogger().info(":adding " + info.toString() + " into " + info.targetConfig.getName());
|
||||
project.getDependencies().add(info.targetConfig.getName(), info.getRemappedNotation());
|
||||
}
|
||||
|
||||
// Report deprecation warnings
|
||||
if (entry.replacedWith() != null && !modDependencies.isEmpty()) {
|
||||
extension.getDeprecationHelper().replaceWithInLoom0_11(entry.sourceConfiguration(), entry.replacedWith());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,10 +147,10 @@ public class RemapConfiguration {
|
||||
|
||||
RemapSourcesJarTask remapSourcesJarTask = (RemapSourcesJarTask) project.getTasks().findByName(remapSourcesJarTaskName);
|
||||
Preconditions.checkNotNull(remapSourcesJarTask, "Could not find " + remapSourcesJarTaskName + " in " + project.getName());
|
||||
remapSourcesJarTask.setOutput(sourcesTask.getArchivePath());
|
||||
remapSourcesJarTask.getOutput().set(sourcesTask.getArchiveFile());
|
||||
String sourcesTaskClassifer = sourcesTask.getArchiveClassifier().get();
|
||||
sourcesTask.getArchiveClassifier().set(sourcesTaskClassifer == null ? "dev" : sourcesTaskClassifer + "-dev");
|
||||
remapSourcesJarTask.setInput(sourcesTask.getArchivePath());
|
||||
remapSourcesJarTask.getInput().set(sourcesTask.getArchiveFile());
|
||||
remapSourcesJarTask.dependsOn(sourcesTask);
|
||||
|
||||
if (isDefaultRemap) {
|
||||
|
||||
@@ -26,8 +26,13 @@ package net.fabricmc.loom.configuration;
|
||||
|
||||
import org.gradle.api.artifacts.ConfigurationContainer;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public record RemappedConfigurationEntry(String sourceConfiguration, String targetConfiguration, boolean isOnModCompileClasspath, String mavenScope, @Nullable String replacedWith) {
|
||||
public RemappedConfigurationEntry(String sourceConfiguration, String targetConfiguration, boolean isOnModCompileClasspath, String mavenScope) {
|
||||
this(sourceConfiguration, targetConfiguration, isOnModCompileClasspath, mavenScope, null);
|
||||
}
|
||||
|
||||
public record RemappedConfigurationEntry(String sourceConfiguration, String targetConfiguration, boolean isOnModCompileClasspath, String mavenScope) {
|
||||
public boolean hasMavenScope() {
|
||||
return mavenScope != null && !mavenScope.isEmpty();
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class RunConfig {
|
||||
runConfig.programArgs = "";
|
||||
|
||||
runConfig.mainClass = "net.fabricmc.devlaunchinjector.Main";
|
||||
runConfig.vmArgs = "-XX:+ShowCodeDetailsInExceptionMessages -Dfabric.dli.config=" + encodeEscaped(extension.getFiles().getDevLauncherConfig().getAbsolutePath()) + " -Dfabric.dli.env=" + environment.toLowerCase();
|
||||
runConfig.vmArgs = "-Dfabric.dli.config=" + encodeEscaped(extension.getFiles().getDevLauncherConfig().getAbsolutePath()) + " -Dfabric.dli.env=" + environment.toLowerCase();
|
||||
|
||||
if (extension.isForge()) {
|
||||
List<String> modClasses = new ArrayList<>();
|
||||
|
||||
@@ -26,9 +26,20 @@ package net.fabricmc.loom.extension;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.initialization.Settings;
|
||||
|
||||
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||
|
||||
public interface LoomFiles {
|
||||
static LoomFiles create(Project project) {
|
||||
return new LoomFilesProjectImpl(project);
|
||||
}
|
||||
|
||||
static LoomFiles create(Settings settings) {
|
||||
return new LoomFilesSettingsImpl(settings);
|
||||
}
|
||||
|
||||
File getUserCache();
|
||||
File getRootProjectPersistentCache();
|
||||
File getProjectPersistentCache();
|
||||
|
||||
@@ -26,32 +26,15 @@ package net.fabricmc.loom.extension;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
public abstract class LoomFilesBaseImpl implements LoomFiles {
|
||||
protected abstract File getGradleUserHomeDir();
|
||||
protected abstract File getRootDir();
|
||||
protected abstract File getProjectDir();
|
||||
protected abstract File getBuildDir();
|
||||
|
||||
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||
public LoomFilesBaseImpl() { }
|
||||
|
||||
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) {
|
||||
private static File createFile(File parent, String child) {
|
||||
File file = new File(parent, child);
|
||||
|
||||
if (!file.exists()) {
|
||||
@@ -63,52 +46,32 @@ public final class LoomFilesImpl implements LoomFiles {
|
||||
|
||||
@Override
|
||||
public File getUserCache() {
|
||||
return userCache;
|
||||
return createFile(getGradleUserHomeDir(), "caches" + File.separator + "fabric-loom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getRootProjectPersistentCache() {
|
||||
return rootProjectPersistentCache;
|
||||
return createFile(getRootDir(), ".gradle" + File.separator + "loom-cache");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getProjectPersistentCache() {
|
||||
return projectPersistentCache;
|
||||
return createFile(getProjectDir(), ".gradle" + File.separator + "loom-cache");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getProjectBuildCache() {
|
||||
return projectBuildCache;
|
||||
return createFile(getBuildDir(), "loom-cache");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getRemappedModCache() {
|
||||
return remappedModCache;
|
||||
return createFile(getRootProjectPersistentCache(), "remapped_mods");
|
||||
}
|
||||
|
||||
@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;
|
||||
return createFile(getUserCache(), "natives/jars");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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.Objects;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
|
||||
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||
|
||||
public final class LoomFilesProjectImpl extends LoomFilesBaseImpl {
|
||||
private final Project project;
|
||||
|
||||
public LoomFilesProjectImpl(Project project) {
|
||||
this.project = Objects.requireNonNull(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getGradleUserHomeDir() {
|
||||
return project.getGradle().getGradleUserHomeDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getRootDir() {
|
||||
return project.getRootDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getProjectDir() {
|
||||
return project.getProjectDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getBuildDir() {
|
||||
return project.getBuildDir();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.Objects;
|
||||
|
||||
import org.gradle.api.initialization.Settings;
|
||||
|
||||
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||
|
||||
public class LoomFilesSettingsImpl extends LoomFilesBaseImpl {
|
||||
private final Settings settings;
|
||||
|
||||
public LoomFilesSettingsImpl(Settings settings) {
|
||||
this.settings = Objects.requireNonNull(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomNatives() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getNativesDirectory(MinecraftProvider minecraftProvider) {
|
||||
throw new IllegalStateException("You can not access natives directory from setting stage");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getGradleUserHomeDir() {
|
||||
return settings.getGradle().getGradleUserHomeDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getRootDir() {
|
||||
return settings.getRootDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getProjectDir() {
|
||||
throw new IllegalStateException("You can not access project directory from setting stage");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File getBuildDir() {
|
||||
throw new IllegalStateException("You can not access project build directory from setting stage");
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
package net.fabricmc.loom.task;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.InputFile;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
@@ -35,29 +35,30 @@ import org.gradle.api.tasks.TaskAction;
|
||||
import net.fabricmc.loom.util.SourceRemapper;
|
||||
|
||||
public class RemapSourcesJarTask extends AbstractLoomTask {
|
||||
private Object input;
|
||||
private Object output;
|
||||
private String from = "named";
|
||||
private String direction;
|
||||
private final RegularFileProperty input = getProject().getObjects().fileProperty();
|
||||
private final RegularFileProperty output = getProject().getObjects().fileProperty().convention(input);
|
||||
private final Property<String> sourceNamespace;
|
||||
private final Property<String> targetNamespace;
|
||||
private SourceRemapper sourceRemapper = null;
|
||||
private boolean preserveFileTimestamps = true;
|
||||
private boolean reproducibleFileOrder = false;
|
||||
private final Property<Boolean> preserveFileTimestamps = getProject().getObjects().property(Boolean.class).convention(true);
|
||||
private final Property<Boolean> reproducibleFileOrder = getProject().getObjects().property(Boolean.class).convention(false);
|
||||
|
||||
public RemapSourcesJarTask() {
|
||||
this.direction = SourceRemapper.intermediary(getProject());
|
||||
this.sourceNamespace = getProject().getObjects().property(String.class).convention("named");
|
||||
this.targetNamespace = getProject().getObjects().property(String.class).convention(SourceRemapper.intermediary(getProject()));
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
public void remap() throws Exception {
|
||||
if (sourceRemapper == null) {
|
||||
if (from.equals(direction)) {
|
||||
SourceRemapper.remapSources(getProject(), getInput(), getOutput(),
|
||||
direction.equals("named") ? SourceRemapper.intermediary(getProject()) : "named", direction, reproducibleFileOrder, preserveFileTimestamps);
|
||||
if (sourceNamespace.get().equals(targetNamespace.get())) {
|
||||
SourceRemapper.remapSources(getProject(), getInput().get().getAsFile(), getOutput().get().getAsFile(),
|
||||
targetNamespace.get().equals("named") ? SourceRemapper.intermediary(getProject()) : "named", targetNamespace.get(), reproducibleFileOrder.get(), preserveFileTimestamps.get());
|
||||
} else {
|
||||
SourceRemapper.remapSources(getProject(), getInput(), getOutput(), from, direction, reproducibleFileOrder, preserveFileTimestamps);
|
||||
SourceRemapper.remapSources(getProject(), getInput().get().getAsFile(), getOutput().get().getAsFile(), sourceNamespace.get(), targetNamespace.get(), reproducibleFileOrder.get(), preserveFileTimestamps.get());
|
||||
}
|
||||
} else {
|
||||
sourceRemapper.scheduleRemapSources(getInput(), getOutput(), reproducibleFileOrder, preserveFileTimestamps);
|
||||
sourceRemapper.scheduleRemapSources(input.get().getAsFile(), output.get().getAsFile(), reproducibleFileOrder.get(), preserveFileTimestamps.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,56 +73,32 @@ public class RemapSourcesJarTask extends AbstractLoomTask {
|
||||
}
|
||||
|
||||
@InputFile
|
||||
public File getInput() {
|
||||
return getProject().file(input);
|
||||
public RegularFileProperty getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@OutputFile
|
||||
public File getOutput() {
|
||||
return getProject().file(output == null ? input : output);
|
||||
public RegularFileProperty getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Input
|
||||
public String getSourceNamespace() {
|
||||
return from;
|
||||
public Property<String> getSourceNamespace() {
|
||||
return sourceNamespace;
|
||||
}
|
||||
|
||||
@Input
|
||||
public String getTargetNamespace() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setInput(Object input) {
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
public void setOutput(Object output) {
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public void setSourceNamespace(String value) {
|
||||
this.from = value;
|
||||
}
|
||||
|
||||
public void setTargetNamespace(String value) {
|
||||
this.direction = value;
|
||||
public Property<String> getTargetNamespace() {
|
||||
return targetNamespace;
|
||||
}
|
||||
|
||||
@Input
|
||||
public boolean isPreserveFileTimestamps() {
|
||||
public Property<Boolean> getPreserveFileTimestamps() {
|
||||
return preserveFileTimestamps;
|
||||
}
|
||||
|
||||
public void setPreserveFileTimestamps(boolean preserveFileTimestamps) {
|
||||
this.preserveFileTimestamps = preserveFileTimestamps;
|
||||
}
|
||||
|
||||
@Input
|
||||
public boolean isReproducibleFileOrder() {
|
||||
public Property<Boolean> getReproducibleFileOrder() {
|
||||
return reproducibleFileOrder;
|
||||
}
|
||||
|
||||
public void setReproducibleFileOrder(boolean reproducibleFileOrder) {
|
||||
this.reproducibleFileOrder = reproducibleFileOrder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,10 @@ public class Constants {
|
||||
public static final List<RemappedConfigurationEntry> MOD_COMPILE_ENTRIES = ImmutableList.of(
|
||||
new RemappedConfigurationEntry("modApi", JavaPlugin.API_CONFIGURATION_NAME, true, "compile"),
|
||||
new RemappedConfigurationEntry("modImplementation", JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, true, "runtime"),
|
||||
new RemappedConfigurationEntry("modRuntime", JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME, false, ""),
|
||||
new RemappedConfigurationEntry("modCompileOnly", JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, true, "")
|
||||
new RemappedConfigurationEntry("modRuntime", JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME, false, "", "modRuntimeOnly"),
|
||||
new RemappedConfigurationEntry("modCompileOnly", JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, true, ""),
|
||||
new RemappedConfigurationEntry("modCompileOnlyApi", JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, true, "compile"),
|
||||
new RemappedConfigurationEntry("modRuntimeOnly", JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME, false, "runtime")
|
||||
);
|
||||
|
||||
private Constants() {
|
||||
|
||||
Reference in New Issue
Block a user