[FEAT] Allow remap task to take in List<Relocation>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
version_major=1
|
version_major=1
|
||||||
version_minor=0
|
version_minor=0
|
||||||
version_patch=0
|
version_patch=1
|
||||||
|
|
||||||
maven_group=com.hypherionmc
|
maven_group=com.hypherionmc
|
||||||
|
|
||||||
|
@@ -8,6 +8,7 @@ import lombok.Getter;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.lucko.jarrelocator.JarRelocator;
|
import me.lucko.jarrelocator.JarRelocator;
|
||||||
|
import me.lucko.jarrelocator.Relocation;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -81,4 +82,24 @@ public final class JarManager {
|
|||||||
// Move the temporary file to the outputJar
|
// Move the temporary file to the outputJar
|
||||||
Files.move(tempJar.toPath(), outputJar.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.move(tempJar.toPath(), outputJar.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relocate or remap packages inside a jar file.
|
||||||
|
* For example, from com.google.gson to lib.com.google.gson
|
||||||
|
* @param inputJar - The input jar file that will be modified
|
||||||
|
* @param outputJar - The file the modified file will be saved to
|
||||||
|
* @param relocations - Packages to relocate. See example above
|
||||||
|
* @throws IOException - Thrown when an IO error occurs
|
||||||
|
*/
|
||||||
|
public void remapJar(File inputJar, File outputJar, List<Relocation> relocations) throws IOException {
|
||||||
|
// Set up temp file, to prevent accidental overwrites
|
||||||
|
File tempJar = new File(inputJar.getParentFile(), "tempRelocated.jar");
|
||||||
|
|
||||||
|
// Run the jar relocater task
|
||||||
|
JarRelocator relocator = new JarRelocator(inputJar, tempJar, relocations);
|
||||||
|
relocator.run();
|
||||||
|
|
||||||
|
// Move the temporary file to the outputJar
|
||||||
|
Files.move(tempJar.toPath(), outputJar.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user