Skip to content

Commit

Permalink
Don't use gradle internal dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Feb 11, 2024
1 parent 2f7f888 commit 56479a3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
implementation "net.fabricmc:mapping-io:0.4.2"
implementation "net.fabricmc:fabric-filament:0.6.2"
implementation("net.fabricmc:fabric-loader:0.15.6")
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.4.2'
}

tasks.withType(JavaCompile) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
multi_filament_version=0.2.2
multi_filament_version=0.2.3

asm_version=9.5
unpick_version=2.3.0
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.legacyfabric.multifilament;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.fabricmc.filament.FilamentGradlePlugin;
import net.fabricmc.filament.task.CombineUnpickDefinitionsTask;

Expand All @@ -10,6 +12,8 @@
import org.gradle.api.tasks.TaskContainer;

public class MultiFilamentGradlePlugin implements Plugin<Project> {
public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

@Override
public void apply(Project project) {
project.getPlugins().apply(FilamentGradlePlugin.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package net.legacyfabric.multifilament.provider;

import org.gradle.internal.impldep.com.google.gson.Gson;
import org.gradle.internal.impldep.com.google.gson.JsonArray;
import org.gradle.internal.impldep.com.google.gson.JsonElement;
import org.gradle.internal.impldep.com.google.gson.JsonObject;
import com.fasterxml.jackson.core.type.TypeReference;
import net.legacyfabric.multifilament.MultiFilamentGradlePlugin;
import net.legacyfabric.multifilament.util.FabricMetaMCVersion;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -24,30 +18,22 @@ default boolean revisionMatch(int revision) {
class FabricLikeMetadata {
private final String url;
private final List<String> versions = new ArrayList<>();
private static final Gson gson = new Gson();

public FabricLikeMetadata(String url) {
this.url = url;
}

private void computeData() {
try {
URL url1 = new URL(url);
TypeReference<List<FabricMetaMCVersion>> metaType = new TypeReference<List<FabricMetaMCVersion>>() {};
List<FabricMetaMCVersion> versions = MultiFilamentGradlePlugin.OBJECT_MAPPER.readValue(url, metaType);

try (InputStream stream = url1.openStream()) {
try (Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
JsonArray array = gson.fromJson(reader, JsonArray.class);

for (JsonElement element : array) {
if (element instanceof JsonObject object) {
if (object.has("version")) {
String version = object.get("version").getAsString();

if (!versions.contains(version)) versions.add(version);
}
}
if (versions != null) {
versions.forEach(v -> {
if (!this.versions.contains(v.version())) {
this.versions.add(v.version());
}
}
});
}
} catch (IOException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.legacyfabric.multifilament.util;

public record FabricMetaMCVersion(String version, boolean stable) {
}

0 comments on commit 56479a3

Please sign in to comment.