Skip to content

Commit

Permalink
Merge branch 'dev/1.3' into dev/1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Johni0702 committed Mar 25, 2024
2 parents 483f292 + 21bfc0f commit f4361aa
Show file tree
Hide file tree
Showing 78 changed files with 1,482 additions and 132 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ jobs:
- name: Upload to Maven
run: ./gradlew publish --stacktrace
env:
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Essential Loom

A fork of [Architectury Loom](https://github.com/architectury/architectury-loom/), primarily to support legacy forge versions
but with some other changes for our purposes. Used by [Essential Gradle Toolkit](https://github.com/EssentialGG/essential-gradle-toolkit/).

Talk to us on [Discord](https://discord.gg/essential). Use the `#programmer-chat` channel for Essential Loom discussions.
Issues can be reported on Discord or using GitHub issues.

# Original Readme

---

# Architectury Loom

Talk to us on [Discord](https://discord.gg/C2RdJDpRBP)!
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/test-project/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'dev.architectury.loom' version '0.13.local'
id 'gg.essential.loom' version '0.13.local'
}

dependencies {
Expand Down
57 changes: 13 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}
}

group = "dev.architectury"
group = "gg.essential"
def baseVersion = '1.4'

def ENV = System.getenv()
Expand Down Expand Up @@ -192,6 +192,9 @@ dependencies {
// Forge mods.toml parsing
implementation libs.night.config.toml

// Legacy Forge patches
implementation libs.lzma

// Testing
testImplementation(gradleTestKit())
testImplementation(testLibs.spock) {
Expand All @@ -205,6 +208,8 @@ dependencies {
testImplementation testLibs.mockito
testImplementation testLibs.java.debug

runtimeOnly testLibs.pack200

compileOnly runtimeLibs.jetbrains.annotations
testCompileOnly runtimeLibs.jetbrains.annotations

Expand Down Expand Up @@ -241,7 +246,7 @@ java {

spotless {
java {
licenseHeaderFile(rootProject.file("HEADER")).yearSeparator("-")
// licenseHeaderFile(rootProject.file("HEADER")).yearSeparator("-")
targetExclude("**/loom/util/DownloadUtil.java", "**/loom/util/FileSystemUtil.java")
targetExclude("**/dev/architectury/**")
}
Expand Down Expand Up @@ -284,7 +289,7 @@ codenarc {
gradlePlugin {
plugins {
fabricLoom {
id = 'dev.architectury.loom'
id = 'gg.essential.loom'
implementationClass = 'net.fabricmc.loom.bootstrap.LoomGradlePluginBootstrap'
}
}
Expand Down Expand Up @@ -326,52 +331,16 @@ test {
import org.gradle.api.internal.artifacts.configurations.ConfigurationRoles
import org.gradle.launcher.cli.KotlinDslVersion
import org.gradle.util.GradleVersion
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.Node

publishing {
publications {
if (isSnapshot) return

// Also publish a snapshot so people can use the latest version if they wish
snapshot(MavenPublication) { publication ->
groupId project.group
artifactId project.base.archivesName.get()
version baseVersion + '-SNAPSHOT'

from components.java
}

// Manually crate the plugin marker for snapshot versions
snapshotPlugin(MavenPublication) {
groupId 'dev.architectury.loom'
artifactId 'dev.architectury.loom.gradle.plugin'
version baseVersion + '-SNAPSHOT'

pom.withXml {
// Based off org.gradle.plugin.devel.plugins.MavenPluginPublishPlugin
Element root = asElement()
Document document = root.getOwnerDocument()
Node dependencies = root.appendChild(document.createElement('dependencies'))
Node dependency = dependencies.appendChild(document.createElement('dependency'))
Node groupId = dependency.appendChild(document.createElement('groupId'))
groupId.setTextContent(project.group)
Node artifactId = dependency.appendChild(document.createElement('artifactId'))
artifactId.setTextContent(project.archivesBaseName)
Node version = dependency.appendChild(document.createElement('version'))
version.setTextContent(baseVersion + '-SNAPSHOT')
}
}
}

repositories {
if (ENV.MAVEN_PASS != null) {
if (System.getenv("NEXUS_USER") != null) {
maven {
url = "https://deploy.shedaniel.me/"
url = "https://repo.sk1er.club/repository/maven-releases/"
name = "nexus-public"
credentials {
username = "shedaniel"
password = ENV.MAVEN_PASS
username = System.getenv("NEXUS_USER")
password = System.getenv("NEXUS_PASSWORD")
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
</module>

<module name="TreeWalker">
<module name="SuppressionCommentFilter"/>

<!-- Ensure all imports are ship shape -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ forge-diffpatch = "2.0.7"
night-config = "3.6.6"
datafixerupper = "6.0.8"
at = "1.0.1"
lzma = "1.3"

[libraries]
# Loom compile libraries
Expand Down Expand Up @@ -64,6 +65,7 @@ forge-diffpatch = { module = "net.minecraftforge:DiffPatch", version.ref = "forg
night-config-toml = { module = "com.electronwill.night-config:toml", version.ref = "night-config" }
datafixerupper = { module = "com.mojang:datafixerupper", version.ref = "datafixerupper" }
at = { module = "dev.architectury:at", version.ref = "at" }
lzma = { module = "com.github.jponge:lzma-java", version.ref = "lzma" }

[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
Expand Down
2 changes: 2 additions & 0 deletions gradle/test.libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ javalin = "5.6.2"
mockito = "5.4.0"
java-debug = "0.48.0"
mixin = "0.11.4+mixin.0.8.5"
pack200 = "0.1.3"

gradle-nightly = "8.5-20230908221250+0000"
fabric-loader = "0.14.22"
Expand All @@ -18,6 +19,7 @@ javalin = { module = "io.javalin:javalin", version.ref = "javalin" }
mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }
java-debug = { module = "com.microsoft.java:com.microsoft.java.debug.core", version.ref = "java-debug" }
mixin = { module = "net.fabricmc:sponge-mixin", version.ref = "mixin" }
pack200 = { module = "dev.architectury.architectury-pack200:dev.architectury.architectury-pack200.gradle.plugin", version.ref = "pack200" }
gradle-nightly = { module = "org.gradle:dummy", version.ref = "gradle-nightly" }
fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" }
fabric-installer = { module = "net.fabricmc:fabric-installer", version.ref = "fabric-installer" }
8 changes: 8 additions & 0 deletions src/main/java/net/fabricmc/loom/LoomGradleExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ default boolean isForgeLikeAndNotOfficial() {
return isForgeLike() && !getMcpConfigProvider().isOfficial();
}

default boolean isLegacyForge() {
return isForge() && getForgeUserdevProvider().isLegacyForge();
}

default boolean isModernForge() {
return isForge() && !isLegacyForge();
}

DependencyProviders getDependencyProviders();

void setDependencyProviders(DependencyProviders dependencyProviders);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/fabricmc/loom/LoomGradlePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ public void apply(Project project) {
if (!loggedVersions.contains(LOOM_VERSION)) {
loggedVersions.add(LOOM_VERSION);
System.setProperty("loom.printed.logged", String.join(",", loggedVersions));
project.getLogger().lifecycle("Architectury Loom: " + LOOM_VERSION);
project.getLogger().lifecycle("Essential Loom: " + LOOM_VERSION);

if (Constants.PLUGIN_BETA) {
project.getLogger().lifecycle("This version of Architectury Loom is in beta! Please report any issues you encounter: https://github.com/architectury/architectury-loom/issues");
project.getLogger().lifecycle("This version of Essential Loom is in beta!");
} else if (Constants.PLUGIN_DEPRECATED) {
project.getLogger().lifecycle("You are using an outdated version of Architectury Loom! This version will not receive any support, please consider updating!");
project.getLogger().lifecycle("You are using an outdated version of Essential Loom! This version will not receive any support, please consider updating!");
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/fabricmc/loom/api/ForgeExtensionAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.gradle.api.provider.SetProperty;
import org.jetbrains.annotations.ApiStatus;

import net.fabricmc.loom.configuration.providers.forge.fg2.Pack200Provider;

/**
* This is the Forge extension API available to build scripts.
*/
Expand Down Expand Up @@ -112,6 +114,8 @@ default void mixinConfig(String... mixinConfigs) {
*/
Property<Boolean> getUseForgeLoggerConfig();

Property<Pack200Provider> getPack200Provider();

/**
* A list of mod IDs for mods applied for data generation.
* The returned list is unmodifiable but not immutable - it will reflect changes done with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@
import net.fabricmc.loom.util.fmj.FabricModJsonFactory;

public final class IncludedJarFactory {
private final Task task;
private final Project project;

public IncludedJarFactory(Project project) {
this.project = project;
public IncludedJarFactory(Task task) {
this.task = task;
this.project = task.getProject();
}

public Provider<ConfigurableFileCollection> getNestedJars(final Configuration configuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import net.fabricmc.loom.configuration.providers.forge.SrgProvider;
import net.fabricmc.loom.configuration.providers.forge.mcpconfig.McpConfigProvider;
import net.fabricmc.loom.configuration.providers.forge.minecraft.ForgeMinecraftProvider;
import net.fabricmc.loom.configuration.providers.mappings.GeneratedIntermediateMappingsProvider;
import net.fabricmc.loom.configuration.providers.mappings.MappingConfiguration;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftJarConfiguration;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftProvider;
Expand All @@ -79,7 +80,9 @@
import net.fabricmc.loom.configuration.sources.ForgeSourcesRemapper;
import net.fabricmc.loom.extension.MixinExtension;
import net.fabricmc.loom.util.Checksum;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.ExceptionUtil;
import net.fabricmc.loom.util.LoomVersions;
import net.fabricmc.loom.util.gradle.GradleUtils;
import net.fabricmc.loom.util.gradle.SourceSetHelper;
import net.fabricmc.loom.util.service.ScopedSharedServiceManager;
Expand Down Expand Up @@ -201,6 +204,18 @@ private synchronized void setupMinecraft(ConfigContext configContext) throws Exc
// but before MinecraftPatchedProvider.provide.
setupDependencyProviders(project, extension);

if (extension.isLegacyForge()) {
extension.setIntermediateMappingsProvider(GeneratedIntermediateMappingsProvider.class, provider -> {
provider.minecraftProvider = minecraftProvider;
});
}

if (extension.isForgeLike() && !extension.isLegacyForge()) {
// Excluded on legacy forge because it pulls in a log4j-api version newer than what forge wants and we don't
// need it anyway
project.getDependencies().add(Constants.Configurations.FORGE_EXTRA, LoomVersions.UNPROTECT.mavenNotation());
}

final DependencyInfo mappingsDep = DependencyInfo.create(getProject(), Configurations.MAPPINGS);
final MappingConfiguration mappingConfiguration = MappingConfiguration.create(getProject(), configContext.serviceManager(), mappingsDep, minecraftProvider);
extension.setMappingConfiguration(mappingConfiguration);
Expand Down Expand Up @@ -380,9 +395,9 @@ public static void setupDependencyProviders(Project project, LoomGradleExtension
}

if (extension.isForgeLike()) {
dependencyProviders.addProvider(new ForgeUniversalProvider(project));
dependencyProviders.addProvider(new McpConfigProvider(project));
dependencyProviders.addProvider(new PatchProvider(project));
dependencyProviders.addProvider(new ForgeUniversalProvider(project));
}

dependencyProviders.handleDependencies(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void run() {
extendsFrom(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME, Constants.Configurations.FORGE_EXTRA);

// Add Forge/NeoForge shared dev-time dependencies
getDependencies().add(Constants.Configurations.FORGE_EXTRA, LoomVersions.UNPROTECT.mavenNotation());
// Note: Unprotect is set up later in CompileConfiguration because we need to skip it on legacy forge
getDependencies().add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, LoomVersions.JAVAX_ANNOTATIONS.mavenNotation());

// Add Forge-only dev-time dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public final void afterEvaluation() {
});

// TODO: Support for env-only jars?
if (extension.isForge() && extension.getMinecraftJarConfiguration().get() == MinecraftJarConfiguration.MERGED) {
if (extension.isForge() && !extension.isLegacyForge() && extension.getMinecraftJarConfiguration().get() == MinecraftJarConfiguration.MERGED) {
project.getTasks().register("genForgePatchedSources", GenerateForgePatchedSourcesTask.class, task -> {
task.setDescription("Decompile Minecraft using Forge's toolchain.");
task.setGroup(Constants.TaskGroup.FABRIC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public LocalMavenHelper(String group, String name, String version, @Nullable Str
}

public Path copyToMaven(Path artifact, @Nullable String classifier) throws IOException {
if (!artifact.getFileName().toString().endsWith(".jar")) {
if (!artifact.getFileName().toString().endsWith(".jar") && !artifact.getFileName().toString().endsWith(".zip")) {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ public static String createForgeMappingsIdentifier(LoomGradleExtension extension
protected void manipulateMappings(Project project, Path mappingsJar) throws IOException {
Stopwatch stopwatch = Stopwatch.createStarted();
LoomGradleExtension extension = LoomGradleExtension.get(project);

if (extension.isLegacyForge()) {
// Legacy forge patches are in official namespace, so if the type of a field is changed by them, then that
// is effectively a new field and not traceable to any mapping. Therefore this does not apply to it.
return;
}

this.rawTinyMappings = tinyMappings;
this.rawTinyMappingsWithSrg = tinyMappingsWithSrg;
this.rawTinyMappingsWithMojang = tinyMappingsWithMojang;
Expand Down
Loading

0 comments on commit f4361aa

Please sign in to comment.