Attempt to fix
This commit is contained in:
parent
2c2efcacda
commit
be41e8d60d
|
@ -24,7 +24,7 @@ allprojects {
|
|||
group = "io.gitlab.jfronny.inceptum"
|
||||
}
|
||||
|
||||
println("Building Inceptum $version")
|
||||
println("Using Inceptum Build Script $version")
|
||||
|
||||
val lwjglVersion by extra("3.3.1")
|
||||
val imguiVersion by extra("1.86.4")
|
||||
|
|
|
@ -115,22 +115,30 @@ public class Updater {
|
|||
}
|
||||
|
||||
private static void downloadLibrary(List<String> repositories, final String artifact, List<String> libraries) throws IOException, URISyntaxException {
|
||||
for (String repository : repositories) {
|
||||
List<Exception> exceptions = new LinkedList<>();
|
||||
for (String repository : Stream.concat(Stream.of(PROJECT_MAVEN), repositories.stream()).toList()) {
|
||||
Pom pom;
|
||||
try {
|
||||
pom = MavenApi.getPom(repository, artifact);
|
||||
} catch (IOException | URISyntaxException | XMLStreamException | SAXException ignored) {
|
||||
} catch (IOException | URISyntaxException | XMLStreamException | SAXException e) {
|
||||
exceptions.add(new Exception("Could not download artifact from " + repository, e));
|
||||
continue;
|
||||
}
|
||||
for (MavenDependency dependency : pom.dependencies) {
|
||||
String mvnName = dependency.groupId + ":" + dependency.artifactId + ":" + dependency.version;
|
||||
downloadLibrary(repositories, mvnName, libraries);
|
||||
if (pom.dependencies != null) {
|
||||
for (MavenDependency dependency : pom.dependencies) {
|
||||
String mvnName = dependency.groupId + ":" + dependency.artifactId + ":" + dependency.version;
|
||||
downloadLibrary(repositories, mvnName, libraries);
|
||||
}
|
||||
}
|
||||
MavenApi.downloadLibrary(repository, artifact);
|
||||
libraries.add(artifact);
|
||||
return;
|
||||
}
|
||||
throw new IOException("Could not find any repository containing the artifact " + artifact + " (searched: " + String.join(", ", repositories) + ")");
|
||||
IOException exception = new IOException("Could not find any repository containing the artifact " + artifact + " (searched: " + String.join(", ", repositories) + ")");
|
||||
for (Exception e : exceptions) {
|
||||
exception.addSuppressed(e);
|
||||
}
|
||||
throw exception;
|
||||
}
|
||||
|
||||
private static Path artifactToPath(String artifact) {
|
||||
|
|
|
@ -44,6 +44,7 @@ public class MavenApi {
|
|||
boolean hasArtifactId = false;
|
||||
boolean hasVersion = false;
|
||||
for (Node node : iterable(doc.getDocumentElement().getChildNodes())) {
|
||||
if (isWhitespace(node)) continue;
|
||||
switch (node.getNodeName()) {
|
||||
case "modelVersion" -> {
|
||||
hasModelVersion = true;
|
||||
|
@ -65,6 +66,7 @@ public class MavenApi {
|
|||
case "dependencies" -> {
|
||||
result.dependencies = new LinkedList<>();
|
||||
for (Node dep : iterable(node.getChildNodes())) {
|
||||
if (isWhitespace(dep)) continue;
|
||||
result.dependencies.add(parseDependency(dep));
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +81,10 @@ public class MavenApi {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean isWhitespace(Node node) {
|
||||
return node.getNodeType() == Node.TEXT_NODE && node.getTextContent().isBlank();
|
||||
}
|
||||
|
||||
private static MavenDependency parseDependency(Node doc) throws IOException {
|
||||
MavenDependency result = new MavenDependency();
|
||||
boolean hasGroupId = false;
|
||||
|
@ -86,6 +92,7 @@ public class MavenApi {
|
|||
boolean hasVersion = false;
|
||||
boolean hasScope = false;
|
||||
for (Node node : iterable(doc.getChildNodes())) {
|
||||
if (isWhitespace(node)) continue;
|
||||
switch (node.getNodeName()) {
|
||||
case "groupId" -> {
|
||||
hasGroupId = true;
|
||||
|
@ -168,9 +175,7 @@ public class MavenApi {
|
|||
String path = lib[0].replace('.', '/') + '/'; // Base
|
||||
path += lib[1] + '/'; // Artifact name
|
||||
path += lib[2] + '/'; // Version
|
||||
if (lib.length == 3) { // artifact-version
|
||||
path += lib[1] + '-' + lib[2];
|
||||
}
|
||||
path += lib[1] + '-' + lib[2]; // artifact-version
|
||||
return path + ".pom";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package io.gitlab.jfronny.inceptum.common.model.maven;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Pom {
|
||||
|
@ -7,6 +9,6 @@ public class Pom {
|
|||
public String groupId;
|
||||
public String artifactId;
|
||||
public String version;
|
||||
public String packaging;
|
||||
public List<MavenDependency> dependencies;
|
||||
@Nullable public String packaging;
|
||||
@Nullable public List<MavenDependency> dependencies;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,11 @@ tasks.shadowJar {
|
|||
exclude("META-INF/**")
|
||||
}
|
||||
|
||||
val javaComponent = components["java"] as AdhocComponentWithVariants
|
||||
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
|
||||
skip()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
if (rootProject.hasProperty("dist.platformOnly")) {
|
||||
|
@ -31,9 +36,7 @@ publishing {
|
|||
}
|
||||
} else {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
artifact(tasks.jar) {
|
||||
builtBy(tasks.jar)
|
||||
}
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class Wrapper {
|
|||
newArgs[0] = "wrapper";
|
||||
System.arraycopy(args, 0, newArgs, 1, args.length);
|
||||
System.out.println("Starting Inceptum ClassLoader");
|
||||
WrapperStrap.switchEnv(classpath,
|
||||
WrapperStrap.bootstrap(classpath,
|
||||
"io.gitlab.jfronny.inceptum.Inceptum",
|
||||
newArgs);
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@ public class WrapperStrap {
|
|||
|
||||
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException, URISyntaxException {
|
||||
Utils.LOGGER.info("Starting Inceptum Wrapper ClassLoader");
|
||||
switchEnv(Set.of(new File(WrapperStrap.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toPath()),
|
||||
bootstrap(Set.of(new File(WrapperStrap.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toPath()),
|
||||
"io.gitlab.jfronny.inceptum.Wrapper",
|
||||
args);
|
||||
}
|
||||
|
||||
public static void switchEnv(Iterable<Path> jars, String mainClass, String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException, URISyntaxException {
|
||||
public static void bootstrap(Iterable<Path> jars, String mainClass, String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException, URISyntaxException {
|
||||
try (WrapperClassLoader loader = new WrapperClassLoader(jars)) {
|
||||
Thread.currentThread().setContextClassLoader(loader);
|
||||
loader.loadClass(mainClass)
|
||||
|
|
Loading…
Reference in New Issue