aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-08-14 14:46:18 +0800
committershedaniel <daniel@shedaniel.me>2021-08-14 14:46:18 +0800
commit6d9065eb1e040df556e6c738ca3093cbed606ad5 (patch)
tree7d61cdccb653c87327b59146e95773aaf6ec2ba3
parent57d5d20816108f1f7b38e9c00bf3bab5d3439558 (diff)
parenta0c2d877af42a908c3600461603a66c6dba5af64 (diff)
downloadarchitectury-loom-6d9065eb1e040df556e6c738ca3093cbed606ad5.tar.gz
architectury-loom-6d9065eb1e040df556e6c738ca3093cbed606ad5.tar.bz2
architectury-loom-6d9065eb1e040df556e6c738ca3093cbed606ad5.zip
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
-rw-r--r--bootstrap/test-project/build.gradle2
-rw-r--r--build.gradle2
-rw-r--r--src/main/java/net/fabricmc/loom/LoomGradlePlugin.java4
-rw-r--r--src/main/java/net/fabricmc/loom/LoomRepositoryPlugin.java140
-rw-r--r--src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java5
-rw-r--r--src/main/java/net/fabricmc/loom/configuration/RemapConfiguration.java4
-rw-r--r--src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java7
-rw-r--r--src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java2
-rw-r--r--src/main/java/net/fabricmc/loom/extension/LoomFiles.java11
-rw-r--r--src/main/java/net/fabricmc/loom/extension/LoomFilesBaseImpl.java (renamed from src/main/java/net/fabricmc/loom/extension/LoomFilesImpl.java)63
-rw-r--r--src/main/java/net/fabricmc/loom/extension/LoomFilesProjectImpl.java80
-rw-r--r--src/main/java/net/fabricmc/loom/extension/LoomFilesSettingsImpl.java70
-rw-r--r--src/main/java/net/fabricmc/loom/task/RemapSourcesJarTask.java73
-rw-r--r--src/main/java/net/fabricmc/loom/util/Constants.java6
-rw-r--r--src/test/resources/projects/mixinApSimple/build.gradle2
15 files changed, 235 insertions, 236 deletions
diff --git a/bootstrap/test-project/build.gradle b/bootstrap/test-project/build.gradle
index f24eaef0..ab88e467 100644
--- a/bootstrap/test-project/build.gradle
+++ b/bootstrap/test-project/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id 'dev.architectury.loom' version '0.9.local'
+ id 'dev.architectury.loom' version '0.10.local'
}
dependencies {
diff --git a/build.gradle b/build.gradle
index 51818859..09c91526 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,7 +22,7 @@ tasks.withType(JavaCompile).configureEach {
group = "dev.architectury"
archivesBaseName = project.name
-def baseVersion = '0.9.1'
+def baseVersion = '0.10.0'
def runNumber = System.getenv("GITHUB_RUN_NUMBER") ?: "9999"
def isSnapshot = System.getenv("PR_NUM") != null
diff --git a/src/main/java/net/fabricmc/loom/LoomGradlePlugin.java b/src/main/java/net/fabricmc/loom/LoomGradlePlugin.java
index 323ab360..9effb56f 100644
--- a/src/main/java/net/fabricmc/loom/LoomGradlePlugin.java
+++ b/src/main/java/net/fabricmc/loom/LoomGradlePlugin.java
@@ -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);
diff --git a/src/main/java/net/fabricmc/loom/LoomRepositoryPlugin.java b/src/main/java/net/fabricmc/loom/LoomRepositoryPlugin.java
index 94ce1c53..06222365 100644
--- a/src/main/java/net/fabricmc/loom/LoomRepositoryPlugin.java
+++ b/src/main/java/net/fabricmc/loom/LoomRepositoryPlugin.java
@@ -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;
- }
-}
diff --git a/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java b/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java
index 9533b343..d113cf8f 100644
--- a/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java
+++ b/src/main/java/net/fabricmc/loom/build/ModCompileRemapper.java
@@ -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());
+ }
});
}
}
diff --git a/src/main/java/net/fabricmc/loom/configuration/RemapConfiguration.java b/src/main/java/net/fabricmc/loom/configuration/RemapConfiguration.java
index 6afcf2c1..8a6c367e 100644
--- a/src/main/java/net/fabricmc/loom/configuration/RemapConfiguration.java
+++ b/src/main/java/net/fabricmc/loom/configuration/RemapConfiguration.java
@@ -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) {
diff --git a/src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java b/src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java
index 228ec34e..5e4cf31d 100644
--- a/src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java
+++ b/src/main/java/net/fabricmc/loom/configuration/RemappedConfigurationEntry.java
@@ -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();
}
diff --git a/src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java b/src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java
index 8c60619f..a8d77353 100644
--- a/src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java
+++ b/src/main/java/net/fabricmc/loom/configuration/ide/RunConfig.java
@@ -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<>();
diff --git a/src/main/java/net/fabricmc/loom/extension/LoomFiles.java b/src/main/java/net/fabricmc/loom/extension/LoomFiles.java
index b24352a8..c93e0272 100644
--- a/src/main/java/net/fabricmc/loom/extension/LoomFiles.java
+++ b/src/main/java/net/fabricmc/loom/extension/LoomFiles.java
@@ -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();
diff --git a/src/main/java/net/fabricmc/loom/extension/LoomFilesImpl.java b/src/main/java/net/fabricmc/loom/extension/LoomFilesBaseImpl.java
index 1dac177d..f99395eb 100644
--- a/src/main/java/net/fabricmc/loom/extension/LoomFilesImpl.java
+++ b/src/main/java/net/fabricmc/loom/extension/LoomFilesBaseImpl.java
@@ -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
diff --git a/src/main/java/net/fabricmc/loom/extension/LoomFilesProjectImpl.java b/src/main/java/net/fabricmc/loom/extension/LoomFilesProjectImpl.java
new file mode 100644
index 00000000..b047dc1f
--- /dev/null
+++ b/src/main/java/net/fabricmc/loom/extension/LoomFilesProjectImpl.java
@@ -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;
+ }
+}
diff --git a/src/main/java/net/fabricmc/loom/extension/LoomFilesSettingsImpl.java b/src/main/java/net/fabricmc/loom/extension/LoomFilesSettingsImpl.java
new file mode 100644
index 00000000..7e12b0cb
--- /dev/null
+++ b/src/main/java/net/fabricmc/loom/extension/LoomFilesSettingsImpl.java
@@ -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");
+ }
+}
diff --git a/src/main/java/net/fabricmc/loom/task/RemapSourcesJarTask.java b/src/main/java/net/fabricmc/loom/task/RemapSourcesJarTask.java
index 0d7506e7..d8cb2e13 100644
--- a/src/main/java/net/fabricmc/loom/task/RemapSourcesJarTask.java
+++ b/src/main/java/net/fabricmc/loom/task/RemapSourcesJarTask.java
@@ -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;
- }
}
diff --git a/src/main/java/net/fabricmc/loom/util/Constants.java b/src/main/java/net/fabricmc/loom/util/Constants.java
index e7fdea26..00687983 100644
--- a/src/main/java/net/fabricmc/loom/util/Constants.java
+++ b/src/main/java/net/fabricmc/loom/util/Constants.java
@@ -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() {
diff --git a/src/test/resources/projects/mixinApSimple/build.gradle b/src/test/resources/projects/mixinApSimple/build.gradle
index 2090d7fa..11fe57e5 100644
--- a/src/test/resources/projects/mixinApSimple/build.gradle
+++ b/src/test/resources/projects/mixinApSimple/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id 'fabric-loom' version '0.9.local'
+ id 'fabric-loom'
id 'maven-publish'
}