Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jab125 committed Jun 19, 2024
1 parent 2960fb7 commit 406bef8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 35 deletions.
54 changes: 27 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -347,38 +347,38 @@ import org.w3c.dom.Node
publishing {
publications {
if (isSnapshot) return
if (!ENV.EXPERIMENTAL) {
if (!ENV.EXPERIMENTAL) {

// 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'
// 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
}
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')
// 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 {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/fabricmc/loom/build/nesting/JarNester.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import org.gradle.api.UncheckedIOException;

Check failure on line 40 in src/main/java/net/fabricmc/loom/build/nesting/JarNester.java

View workflow job for this annotation

GitHub Actions / build

Extra separation in import group before 'org.gradle.api.UncheckedIOException'
import org.slf4j.Logger;

import net.fabricmc.loom.build.nesting.NestableJarGenerationTask.NestedFile;
import net.fabricmc.loom.LoomGradlePlugin;
import net.fabricmc.loom.build.nesting.IncludedJarFactory.NestedFile;
import net.fabricmc.loom.util.ModPlatform;
import net.fabricmc.loom.util.Pair;
import net.fabricmc.loom.util.ZipUtils;
Expand Down Expand Up @@ -146,7 +147,7 @@ private static void handleForgeJarJar(List<NestedFile> forgeJars, File modJar, L
JsonArray nestedJars = new JsonArray();

for (NestedFile nestedFile : forgeJars) {
IncludedJarFactory.Metadata metadata = nestedFile.metadata();
NestableJarGenerationTask.Metadata metadata = nestedFile.metadata();
File file = nestedFile.file();
String nestedJarPath = "META-INF/jars/" + file.getName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.google.common.hash.Hashing;
import com.google.gson.JsonObject;

import net.fabricmc.loom.LoomGradleExtension;

import org.apache.commons.io.FileUtils;

Check failure on line 46 in src/main/java/net/fabricmc/loom/build/nesting/NestableJarGenerationTask.java

View workflow job for this annotation

GitHub Actions / build

Wrong order for 'org.apache.commons.io.FileUtils' import.
import org.gradle.api.DefaultTask;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ArtifactView;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.component.ComponentIdentifier;
Expand All @@ -50,6 +55,7 @@
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.OutputDirectory;
Expand Down Expand Up @@ -222,7 +228,7 @@ private void makeNestableJar(final File input, final File output, final String m
throw new UncheckedIOException("Failed to copy mod file %s".formatted(input), e);
}

if (FabricModJsonFactory.isModJar(input)) {
if (FabricModJsonFactory.isModJar(input, LoomGradleExtension.get(getProject()).getPlatform().get())) {
// Input is a mod, nothing needs to be done.
return;
}
Expand All @@ -249,4 +255,16 @@ public String toString() {
return group + ":" + name + ":" + version + classifier();
}
}

public record NestedFile(Metadata metadata, File file) implements Serializable { }

public record LazyNestedFile(Metadata metadata, Provider<File> file) implements Serializable {
public LazyNestedFile(Project project, Metadata metadata, Supplier<File> file) {
this(metadata, project.provider(file::get));
}

public NestedFile resolve() {
return new NestedFile(metadata, file.get());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import javax.inject.Inject;

Check failure on line 35 in src/main/java/net/fabricmc/loom/extension/LoomGradleExtensionImpl.java

View workflow job for this annotation

GitHub Actions / build

'javax.inject.Inject' should be separated from previous imports.

import com.google.common.base.Suppliers;
import javax.inject.Inject;

import org.gradle.api.Project;

Check failure on line 39 in src/main/java/net/fabricmc/loom/extension/LoomGradleExtensionImpl.java

View workflow job for this annotation

GitHub Actions / build

Extra separation in import group before 'org.gradle.api.Project'
import org.gradle.api.configuration.BuildFeatures;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/fabricmc/loom/task/RemapJarTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@

import com.google.gson.JsonObject;
import dev.architectury.loom.extensions.ModBuildExtensions;

import net.fabricmc.loom.build.nesting.NestableJarGenerationTask.NestedFile;

import org.gradle.api.artifacts.Configuration;

Check failure on line 50 in src/main/java/net/fabricmc/loom/task/RemapJarTask.java

View workflow job for this annotation

GitHub Actions / build

Wrong order for 'org.gradle.api.artifacts.Configuration' import.

Check failure on line 50 in src/main/java/net/fabricmc/loom/task/RemapJarTask.java

View workflow job for this annotation

GitHub Actions / build

Unused import - org.gradle.api.artifacts.Configuration.
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.file.ConfigurableFileCollection;
Expand All @@ -59,7 +62,6 @@
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskDependency;
import org.gradle.api.tasks.TaskProvider;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
Expand All @@ -70,11 +72,10 @@
import net.fabricmc.accesswidener.AccessWidenerRemapper;
import net.fabricmc.accesswidener.AccessWidenerWriter;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.build.nesting.IncludedJarFactory;
import net.fabricmc.loom.build.nesting.IncludedJarFactory.LazyNestedFile;
import net.fabricmc.loom.build.nesting.IncludedJarFactory.NestedFile;
import net.fabricmc.loom.build.nesting.JarNester;
import net.fabricmc.loom.build.nesting.NestableJarGenerationTask;
import net.fabricmc.loom.build.nesting.NestableJarGenerationTask.LazyNestedFile;

Check failure on line 77 in src/main/java/net/fabricmc/loom/task/RemapJarTask.java

View workflow job for this annotation

GitHub Actions / build

Unused import - net.fabricmc.loom.build.nesting.NestableJarGenerationTask.LazyNestedFile.
import net.fabricmc.loom.build.nesting.NestableJarGenerationTask.NestedFile;

Check failure on line 78 in src/main/java/net/fabricmc/loom/task/RemapJarTask.java

View workflow job for this annotation

GitHub Actions / build

Duplicate import to line 48 - net.fabricmc.loom.build.nesting.NestableJarGenerationTask.NestedFile.
import net.fabricmc.loom.configuration.accesswidener.AccessWidenerFile;
import net.fabricmc.loom.configuration.mods.ArtifactMetadata;
import net.fabricmc.loom.extension.MixinExtension;
Expand Down

0 comments on commit 406bef8

Please sign in to comment.