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

Dynamic launcher #12

Merged
merged 3 commits into from
Dec 30, 2024
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
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
<module>smoothcloud-launcher</module>
</modules>

<distributionManagement>
<repository>
<id>smoothcloud-dev</id>
<name>SmoothCloud Repository</name>
<url>https://repository.smoothcloud.eu/dev</url>
</repository>
</distributionManagement>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
package eu.smoothcloud.launcher;

import eu.smoothcloud.launcher.dependency.DependencyLoader;
import eu.smoothcloud.launcher.util.JarLoader;
import eu.smoothcloud.launcher.dependency.DependencyHandler;
import eu.smoothcloud.launcher.loader.JarLoader;
import eu.smoothcloud.launcher.loader.JsonLoader;

import java.nio.file.Path;
import java.io.IOException;

public class SmoothCloudLauncher {
private static SmoothCloudClassLoader classLoader;
private static DependencyLoader dependencyLoader;
private static DependencyHandler dependencyHandler;
private static JsonLoader jsonLoader;
private static JarLoader jarLoader;

public static void main(String[] args) {
// TODO: Add check if launcher is up-to-date and if not -> update
public static void main(String[] args) throws IOException {
classLoader = new SmoothCloudClassLoader();
dependencyLoader = new DependencyLoader("dependencies");
dependencyLoader.loadDependencys();
System.out.println("Start Node Module!");
dependencyHandler = new DependencyHandler();
jsonLoader = new JsonLoader("https://github.com/SmoothCloudEU/smoothcloud-manifest/raw/refs/heads/master/dependencyLoader.json");
jsonLoader.processJsonAndDownload();
System.out.println("Starting smoothcloud-node...");
jarLoader = new JarLoader();
jarLoader.loadJar(Path.of("dependencies/eu.smoothcloud/smoothcloud-node-1.0.0-dev.jar"), args);
System.out.println("SMOOTHCLOUD-NODE: " + dependencyHandler.getDependencyPaths().get("smoothcloud-node"));
jarLoader.loadJar(dependencyHandler.getDependencyPaths().get("smoothcloud-node"), args);
}

public static SmoothCloudClassLoader getClassLoader() {
return classLoader;
}

public static DependencyLoader getDependencyLoader() {
return dependencyLoader;
public static DependencyHandler getDependencyHandler() {
return dependencyHandler;
}

public static JsonLoader getJsonLoader() {
return jsonLoader;
}

public static JarLoader getJarLoader() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package eu.smoothcloud.launcher.dependency;

import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class DependencyHandler {
private final Map<String, Path> dependencyPaths;

public DependencyHandler() {
this.dependencyPaths = new HashMap<>();
}

public String buildUrl(String groupId, String artifactId, String version, String repository, String json) {
Pattern pattern = Pattern.compile("\"name\": \"" + repository + "\",\\s*\"url\": \"([^\"]+)\"");
Matcher matcher = Pattern.compile(pattern.pattern()).matcher(json);
String repoUrl = "";
if (matcher.find()) {
repoUrl = matcher.group(1);
}

// URL erstellen
return String.format(repoUrl, groupId.replace('.', '/'), artifactId, version, artifactId, version);
}

public Map<String, Path> getDependencyPaths() {
return dependencyPaths;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading