mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-27 19:57:00 -05:00
Remove loom bootstrap (#1261)
* Remove bootstrap, its no longer required as Gradle has a nicer error message for outdated java. * No need to check idea or gradle version
This commit is contained in:
7
bootstrap/.gitignore
vendored
7
bootstrap/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
# Ignore everything
|
||||
/*
|
||||
|
||||
!/src
|
||||
!/build.gradle
|
||||
!/.gitignore
|
||||
!/test-project
|
||||
@@ -1,32 +0,0 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'groovy'
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
it.options.release = 8
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation gradleApi()
|
||||
|
||||
testImplementation(gradleTestKit())
|
||||
testImplementation('org.spockframework:spock-core:2.3-groovy-3.0') {
|
||||
exclude module: 'groovy-all'
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
maxHeapSize = "4096m"
|
||||
useJUnitPlatform()
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package net.fabricmc.loom.bootstrap;
|
||||
|
||||
import org.gradle.api.plugins.PluginAware;
|
||||
|
||||
public interface BootstrappedPlugin {
|
||||
void apply(PluginAware project);
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package net.fabricmc.loom.bootstrap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.configuration.BuildFeatures;
|
||||
import org.gradle.api.plugins.PluginAware;
|
||||
import org.gradle.util.GradleVersion;
|
||||
|
||||
/**
|
||||
* This bootstrap is compiled against a minimal gradle API and java 8, this allows us to show a nice error to users who run on unsupported configurations.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class LoomGradlePluginBootstrap implements Plugin<PluginAware> {
|
||||
private static final String MIN_SUPPORTED_GRADLE_VERSION = "8.12";
|
||||
private static final int MIN_SUPPORTED_MAJOR_JAVA_VERSION = 17;
|
||||
private static final int MIN_SUPPORTED_MAJOR_IDEA_VERSION = 2022;
|
||||
|
||||
private static final String PLUGIN_CLASS_NAME = "net.fabricmc.loom.LoomGradlePlugin";
|
||||
private static final String IDEA_VERSION_PROP_KEY = "idea.version";
|
||||
|
||||
@Inject
|
||||
protected abstract BuildFeatures getBuildFeatures();
|
||||
|
||||
@Override
|
||||
public void apply(PluginAware pluginAware) {
|
||||
if (pluginAware instanceof Project) {
|
||||
Project project = (Project) pluginAware;
|
||||
|
||||
if (getBuildFeatures().getIsolatedProjects().getActive().get() || project.findProperty("fabric.loom.skip-env-validation") == null) {
|
||||
validateEnvironment();
|
||||
} else {
|
||||
project.getLogger().lifecycle("Loom environment validation disabled. Please re-enable before reporting any issues.");
|
||||
}
|
||||
}
|
||||
|
||||
getActivePlugin().apply(pluginAware);
|
||||
}
|
||||
|
||||
private void validateEnvironment() {
|
||||
List<String> errors = new ArrayList<>();
|
||||
|
||||
if (!isValidGradleRuntime()) {
|
||||
errors.add(String.format("You are using an outdated version of Gradle (%s). Gradle %s or higher is required.", GradleVersion.current().getVersion(), MIN_SUPPORTED_GRADLE_VERSION));
|
||||
}
|
||||
|
||||
if (!isValidJavaRuntime()) {
|
||||
errors.add(String.format("You are using an outdated version of Java (%s). Java %d or higher is required.", JavaVersion.current().getMajorVersion(), MIN_SUPPORTED_MAJOR_JAVA_VERSION));
|
||||
|
||||
if (Boolean.getBoolean("idea.active")) {
|
||||
// Idea specific error
|
||||
errors.add("You can change the Java version in the Gradle settings dialog.");
|
||||
} else {
|
||||
String javaHome = System.getenv("JAVA_HOME");
|
||||
|
||||
if (javaHome != null) {
|
||||
errors.add(String.format("The JAVA_HOME environment variable is currently set to (%s).", javaHome));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidIdeaRuntime()) {
|
||||
errors.add(String.format("You are using an outdated version of intellij idea (%s). Intellij idea %d or higher is required.", System.getProperty(IDEA_VERSION_PROP_KEY), MIN_SUPPORTED_MAJOR_IDEA_VERSION));
|
||||
}
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
throw new UnsupportedOperationException(String.join("\n", errors));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isValidJavaRuntime() {
|
||||
// Note use compareTo to ensure compatibility with gradle < 6.0
|
||||
return JavaVersion.current().compareTo(JavaVersion.toVersion(MIN_SUPPORTED_MAJOR_JAVA_VERSION)) >= 0;
|
||||
}
|
||||
|
||||
private static boolean isValidGradleRuntime() {
|
||||
return GradleVersion.current().compareTo(GradleVersion.version(MIN_SUPPORTED_GRADLE_VERSION)) >= 0;
|
||||
}
|
||||
|
||||
private static boolean isValidIdeaRuntime() {
|
||||
String version = System.getProperty(IDEA_VERSION_PROP_KEY);
|
||||
|
||||
if (version == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int ideaYear = Integer.parseInt(version.substring(0, version.indexOf(".")));
|
||||
return ideaYear >= MIN_SUPPORTED_MAJOR_IDEA_VERSION;
|
||||
}
|
||||
|
||||
BootstrappedPlugin getActivePlugin() {
|
||||
try {
|
||||
return (BootstrappedPlugin) Class.forName(PLUGIN_CLASS_NAME).getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to bootstrap loom", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '0.13.local'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:1.16.5"
|
||||
mappings loom.officialMojangMappings()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
29
build.gradle
29
build.gradle
@@ -54,15 +54,6 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
configurations {
|
||||
bootstrap {
|
||||
transitive = false
|
||||
}
|
||||
compileClasspath.extendsFrom bootstrap
|
||||
runtimeClasspath.extendsFrom bootstrap
|
||||
testRuntimeClasspath.extendsFrom bootstrap
|
||||
}
|
||||
|
||||
configurations.configureEach {
|
||||
resolutionStrategy {
|
||||
failOnNonReproducibleResolution()
|
||||
@@ -101,8 +92,6 @@ sourceSets {
|
||||
dependencies {
|
||||
implementation gradleApi()
|
||||
|
||||
bootstrap project(":bootstrap")
|
||||
|
||||
// libraries
|
||||
implementation libs.commons.io
|
||||
implementation libs.gson
|
||||
@@ -180,7 +169,6 @@ jar {
|
||||
attributes 'Implementation-Version': project.version
|
||||
}
|
||||
|
||||
from configurations.bootstrap.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
from sourceSets.commonDecompiler.output.classesDirs
|
||||
from sourceSets.cfr.output.classesDirs
|
||||
from sourceSets.fernflower.output.classesDirs
|
||||
@@ -249,7 +237,7 @@ gradlePlugin {
|
||||
plugins {
|
||||
fabricLoom {
|
||||
id = 'fabric-loom'
|
||||
implementationClass = 'net.fabricmc.loom.bootstrap.LoomGradlePluginBootstrap'
|
||||
implementationClass = 'net.fabricmc.loom.LoomGradlePlugin'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -341,21 +329,6 @@ publishing {
|
||||
}
|
||||
}
|
||||
|
||||
// Need to tweak this file to pretend we are compatible with j8 so the bootstrap will run.
|
||||
tasks.withType(GenerateModuleMetadata).configureEach {
|
||||
doLast {
|
||||
def file = outputFile.get().asFile
|
||||
|
||||
def metadata = new groovy.json.JsonSlurper().parseText(file.text)
|
||||
|
||||
metadata.variants.each {
|
||||
it.attributes["org.gradle.jvm.version"] = 8
|
||||
}
|
||||
|
||||
file.text = groovy.json.JsonOutput.toJson(metadata)
|
||||
}
|
||||
}
|
||||
|
||||
// A task to output a json file with a list of all the test to run
|
||||
tasks.register('writeActionsTestMatrix') {
|
||||
doLast {
|
||||
|
||||
@@ -9,6 +9,4 @@ dependencyResolutionManagement {
|
||||
from(files("gradle/runtime.libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include "bootstrap"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2016-2023 FabricMC
|
||||
* Copyright (c) 2016-2025 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
|
||||
@@ -30,16 +30,16 @@ import java.util.Objects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.plugins.PluginAware;
|
||||
|
||||
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
|
||||
import net.fabricmc.loom.api.fabricapi.FabricApiExtension;
|
||||
import net.fabricmc.loom.bootstrap.BootstrappedPlugin;
|
||||
import net.fabricmc.loom.configuration.CompileConfiguration;
|
||||
import net.fabricmc.loom.configuration.fabricapi.FabricApiExtensionImpl;
|
||||
import net.fabricmc.loom.configuration.LoomConfigurations;
|
||||
import net.fabricmc.loom.configuration.MavenPublication;
|
||||
import net.fabricmc.loom.configuration.fabricapi.FabricApiExtensionImpl;
|
||||
import net.fabricmc.loom.configuration.ide.idea.IdeaConfiguration;
|
||||
import net.fabricmc.loom.configuration.sandbox.SandboxConfiguration;
|
||||
import net.fabricmc.loom.decompilers.DecompilerConfiguration;
|
||||
@@ -49,7 +49,7 @@ import net.fabricmc.loom.task.LoomTasks;
|
||||
import net.fabricmc.loom.task.RemapTaskConfiguration;
|
||||
import net.fabricmc.loom.util.LibraryLocationLogger;
|
||||
|
||||
public class LoomGradlePlugin implements BootstrappedPlugin {
|
||||
public class LoomGradlePlugin implements Plugin<PluginAware> {
|
||||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
public static final String LOOM_VERSION = Objects.requireNonNullElse(LoomGradlePlugin.class.getPackage().getImplementationVersion(), "0.0.0+unknown");
|
||||
|
||||
@@ -76,8 +76,9 @@ public class LoomGradlePlugin implements BootstrappedPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void apply(Project project) {
|
||||
private void apply(Project project) {
|
||||
project.getLogger().lifecycle("Fabric Loom: " + LOOM_VERSION);
|
||||
|
||||
LibraryLocationLogger.logLibraryVersions();
|
||||
|
||||
// Apply default plugins
|
||||
|
||||
Reference in New Issue
Block a user