Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.2.3.0 branch #46

Merged
merged 8 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,28 @@ task sourceJar(type: Jar) {

tasks.register('checkArtifactExists') {
doLast {
// Skip this task if --force is present
if (project.hasProperty('force')) {
logger.lifecycle("Skipping artifact existence check due to --force flag.")
return
}

def repoUrl = project.hasProperty('mavenRepoUrl') ? project.mavenRepoUrl : mavenLocalUrl
def artifactPath = "${repoUrl}/${project.group.replace('.', '/')}/com/wildermods/workspace/gradle/plugin/${project.version}/workspace-${project.version}.jar"
def artifactName = "com.wildermods.workspace.gradle.plugin"
def artifactPath = "${repoUrl}/${project.group.replace('.', '/')}/${project.archivesBaseName}/${artifactName}/${project.version}/${artifactName}-${project.version}.jar"
logger.lifecycle("Checking if artifact exists at: $artifactPath")

if (artifactPath.startsWith('file:/')) {
def file = new File(new URI(artifactPath))
if (file.exists()) {
throw new IllegalStateException("Artifact '${project.group}:${project.archivesBaseName}:${project.version}' already exists. Publishing aborted.")
throw new IllegalStateException("Artifact '${artifactPath}' already exists. Publishing aborted.")
}
} else {
def url = new URL(artifactPath)
def connection = url.openConnection()
connection.setRequestMethod('HEAD')
if (connection.responseCode == 200) {
throw new IllegalStateException("Artifact '${project.group}:${project.archivesBaseName}:${project.version}' already exists. Publishing aborted.")
throw new IllegalStateException("Artifact '${artifactPath}' already exists. Publishing aborted.")
}
}
logger.lifecycle("Artifact does not exist, proceeding with publish.")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#The version of the WilderWorkspace gradle plugin
workspaceVersion = 4.2.1.0
workspaceVersion = 4.2.3.0
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ commons_lang_version = "3.17.0"
commons_text_version = "1.13.0"
commons_io_version = "2.18.0"
fabric_loom_version = "1.9.2"
provider_version = "1.7.1.0"
log4j_version = "2.24.3"
provider_version = "1.7.0.0"
vineflower_version = "1.10.1"
gson_version = "2.11.0"
fabric_loader_version = "0.16.9"
Expand All @@ -25,4 +25,4 @@ log4j_slf4j2_impl = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", ver


[bundles]
fabric = ["fabric-loader", "fabric-loom", "vineflower", "provider", "log4j-core", "log4j-api", "log4j-slf4j2-impl"]
fabric = ["fabric-loader", "fabric-loom", "vineflower", "provider", "log4j-core", "log4j-api", "log4j-slf4j2-impl"]
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import java.io.File;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.util.HashSet;
Expand Down Expand Up @@ -176,14 +175,16 @@ private void addPluginDependencies(Project project) {

buildscript.getConfigurations().forEach((config -> {
Set<File> dependencies = config.resolve();
VisitableURLClassLoader classLoader = (VisitableURLClassLoader) WilderWorkspacePlugin.class.getClassLoader();
for(File dependency : dependencies) {
try {
try(VisitableURLClassLoader classLoader = (VisitableURLClassLoader) WilderWorkspacePlugin.class.getClassLoader()) {
for(File dependency : dependencies) {
classLoader.addURL(dependency.toURI().toURL());
} catch (MalformedURLException e) {
throw new LinkageError("Could not resolve dependency", e);
}
}
catch(Throwable t) {
throw new LinkageError("Could not resolve dependency", t);
}

}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
import net.fabricmc.loom.decompilers.ClassLineNumbers;
import net.fabricmc.loom.decompilers.LineNumberRemapper;

/**
* Task to decompile JAR files and remap their line numbers.
* <p>
* This task identifies specific JAR files to decompile, adds other JAR files as libraries, and processes
* line number mappings to produce decompiled sources with accurate line numbers.
* </p>
*/
public class DecompileJarsTask extends DefaultTask {

@Input
Expand All @@ -43,7 +36,7 @@ public void decompile() throws IOException {
DecompilerBuilder b = new DecompilerBuilder(this);
b.setDecompDest(Path.of(decompDir));
HashMap<String, Path> compiledJars = new HashMap<String, Path>();
HashMap<String, Path> lineMappedJarDests = new HashMap<String, Path>();
HashMap<String, Path> decompiledJarDests = new HashMap<String, Path>();

/*
* Add jars to decompile
Expand All @@ -68,7 +61,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
case "wildermyth.jar":
System.out.println("Adding " + file.toAbsolutePath().normalize().toString() + " as input for the decompiler.");
compiledJars.put(file.getFileName().toString(), file);
lineMappedJarDests.put(file.getFileName().toString(), compiledDir.resolve(GameJars.fromPath(file).getPath()));
decompiledJarDests.put(file.getFileName().toString(), compiledDir.resolve("remapped").resolve(GameJars.fromPath(file).getPath()));
b.addJarsToDecomp(file.normalize().toAbsolutePath());
return FileVisitResult.CONTINUE;
}
Expand Down Expand Up @@ -111,9 +104,9 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
WilderWorkspaceDecompiler decompiler = b.build();
decompiler.decompile();

Path linemapDir = Path.of(decompDir).resolve("linemaps");
Path linemapDir = Path.of(decompDir).resolve("decomp").resolve("linemaps");
if(Files.exists(linemapDir)) {
Files.walkFileTree(Path.of(decompDir).resolve("linemaps"), new SimpleFileVisitor<Path>() {
Files.walkFileTree(linemapDir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
if(!dir.equals(linemapDir)) { //there are no subdirectories we want to visit
Expand All @@ -130,7 +123,7 @@ public FileVisitResult visitFile(Path linemap, BasicFileAttributes attrs) throws
if(Files.exists(unmappedJar)) {
System.out.println("Found jar to remap: " + unmappedJar.getFileName());
try {
remap(linemap, unmappedJar, lineMappedJarDests.get(jarName));
remap(linemap, unmappedJar, decompiledJarDests.get(jarName));
} catch (Throwable e) {
throw new IOException(e);
}
Expand Down Expand Up @@ -162,7 +155,7 @@ private void remap(Path linemap, Path jarToRemap, Path remappedJarDest) throws T
ClassLineNumbers lineNumbers = ClassLineNumbers.readMappings(linemap);
LineNumberRemapper remapper = new LineNumberRemapper(lineNumbers);
if(Files.notExists(remappedJarDest)) {
//Files.createFile(remappedJarDest);
Files.createDirectories(remappedJarDest.getParent());
}
remapper.process(jarToRemap, remappedJarDest);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/wildermods/workspace/util/Version.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wildermods.workspace.util;

@SuppressWarnings("rawtypes")
public class Version implements Comparable {

private static final String SPLITTER = "\\.";
Expand Down
Loading