Makes the project into a Maven project
Some checks failed
KnarCraft/Minecraft-Server-Launcher/master There was a failure building this commit

Moves stuff around
Adds Jenkinsfile
Changes some package names
Replaces library with Maven dependency
This commit is contained in:
Kristian Knarvik 2020-02-12 21:30:36 +01:00
parent 4901ea0627
commit 194686b9d8
17 changed files with 96 additions and 69 deletions

24
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,24 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
sh 'mvn clean & mvn validate & mvn compile'
}
}
stage('Test') {
steps {
echo 'Testing...'
sh 'mvn clean & mvn test'
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
sh 'mvn clean & mvn compile & mvn package & mvn verify & mvn install'
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
}
}
}
}

4
META-INF/MANIFEST.MF Normal file
View File

@ -0,0 +1,4 @@
Manifest-Version: 1.0
Class-Path: gson-2.8.5.jar
Main-Class: net.knarcraft.minecraftserverlauncher.Main

Binary file not shown.

View File

@ -1,4 +0,0 @@
Manifest-Version: 1.0
Class-Path: gson-2.8.5.jar
Main-Class: net.knarcraft.serverlauncher.Main

View File

@ -1,14 +1,14 @@
package net.knarcraft.serverlauncher; package net.knarcraft.minecraftserverlauncher;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import net.knarcraft.serverlauncher.profile.Collection; import net.knarcraft.minecraftserverlauncher.profile.Collection;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.minecraftserverlauncher.profile.Profile;
import net.knarcraft.serverlauncher.server.Server; import net.knarcraft.minecraftserverlauncher.server.Server;
import net.knarcraft.serverlauncher.server.ServerType; import net.knarcraft.minecraftserverlauncher.server.ServerType;
import net.knarcraft.serverlauncher.userinterface.ServerConsoles; import net.knarcraft.minecraftserverlauncher.userinterface.ServerConsoles;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import javax.swing.*; import javax.swing.*;
@ -20,9 +20,9 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static net.knarcraft.serverlauncher.Shared.downloadFile; import static net.knarcraft.minecraftserverlauncher.Shared.downloadFile;
import static net.knarcraft.serverlauncher.Shared.readFile; import static net.knarcraft.minecraftserverlauncher.Shared.readFile;
import static net.knarcraft.serverlauncher.Shared.stringBetween; import static net.knarcraft.minecraftserverlauncher.Shared.stringBetween;
//Java 8 required. //Java 8 required.
/** /**

View File

@ -1,4 +1,4 @@
package net.knarcraft.serverlauncher; package net.knarcraft.minecraftserverlauncher;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -1,9 +1,9 @@
package net.knarcraft.serverlauncher.profile; package net.knarcraft.minecraftserverlauncher.profile;
import net.knarcraft.serverlauncher.server.Server; import net.knarcraft.minecraftserverlauncher.userinterface.ServerTab;
import net.knarcraft.serverlauncher.userinterface.ServerConsoles; import net.knarcraft.minecraftserverlauncher.server.Server;
import net.knarcraft.serverlauncher.userinterface.ServerTab; import net.knarcraft.minecraftserverlauncher.userinterface.ServerConsoles;
import net.knarcraft.serverlauncher.userinterface.Console; import net.knarcraft.minecraftserverlauncher.userinterface.Console;
/** /**
* Acts as a wrapper for objects necessary for each server. * Acts as a wrapper for objects necessary for each server.

View File

@ -1,15 +1,15 @@
package net.knarcraft.serverlauncher.profile; package net.knarcraft.minecraftserverlauncher.profile;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import net.knarcraft.serverlauncher.server.AdvancedServerType; import net.knarcraft.minecraftserverlauncher.userinterface.GUI;
import net.knarcraft.serverlauncher.server.Server; import net.knarcraft.minecraftserverlauncher.userinterface.ServerConsoles;
import net.knarcraft.serverlauncher.server.ServerType; import net.knarcraft.minecraftserverlauncher.userinterface.ServerTab;
import net.knarcraft.serverlauncher.userinterface.GUI; import net.knarcraft.minecraftserverlauncher.server.AdvancedServerType;
import net.knarcraft.serverlauncher.userinterface.ServerConsoles; import net.knarcraft.minecraftserverlauncher.server.Server;
import net.knarcraft.serverlauncher.userinterface.ServerTab; import net.knarcraft.minecraftserverlauncher.server.ServerType;
import net.knarcraft.serverlauncher.Main; import net.knarcraft.minecraftserverlauncher.Main;
import javax.swing.*; import javax.swing.*;
import java.io.*; import java.io.*;
@ -20,9 +20,9 @@ import java.util.Objects;
import java.util.Scanner; import java.util.Scanner;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import static net.knarcraft.serverlauncher.Shared.downloadFile; import static net.knarcraft.minecraftserverlauncher.Shared.downloadFile;
import static net.knarcraft.serverlauncher.Shared.readFile; import static net.knarcraft.minecraftserverlauncher.Shared.readFile;
import static net.knarcraft.serverlauncher.Shared.stringBetween; import static net.knarcraft.minecraftserverlauncher.Shared.stringBetween;
/** /**
* Contains all user settings, and a list of servers. * Contains all user settings, and a list of servers.

View File

@ -1,4 +1,4 @@
package net.knarcraft.serverlauncher.server; package net.knarcraft.minecraftserverlauncher.server;
/** /**
* A more advanced servertype for particularly tricky jar downloads. * A more advanced servertype for particularly tricky jar downloads.

View File

@ -1,11 +1,12 @@
package net.knarcraft.serverlauncher.server; package net.knarcraft.minecraftserverlauncher.server;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import net.knarcraft.serverlauncher.Main; import net.knarcraft.minecraftserverlauncher.Shared;
import net.knarcraft.serverlauncher.profile.Collection; import net.knarcraft.minecraftserverlauncher.profile.Collection;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.minecraftserverlauncher.profile.Profile;
import net.knarcraft.minecraftserverlauncher.Main;
import java.io.*; import java.io.*;
import java.nio.file.Path; import java.nio.file.Path;
@ -13,8 +14,6 @@ import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static net.knarcraft.serverlauncher.Shared.*;
/** /**
* Contains all necessary information to create, run and manage a Minecraft server. * Contains all necessary information to create, run and manage a Minecraft server.
@ -365,7 +364,7 @@ public class Server {
case "Spigot": case "Spigot":
case "Craftbukkit": case "Craftbukkit":
case "MCPCplus": case "MCPCplus":
if (!(file.isFile() || downloadFile(url + name + ver + ".jar", filePath))) { if (!(file.isFile() || Shared.downloadFile(url + name + ver + ".jar", filePath))) {
throw new FileNotFoundException("Jar file could not be downloaded."); throw new FileNotFoundException("Jar file could not be downloaded.");
} }
break; break;
@ -374,7 +373,7 @@ public class Server {
type = (AdvancedServerType) this.type; type = (AdvancedServerType) this.type;
if (this.serverVersion.equals("Latest")) { if (this.serverVersion.equals("Latest")) {
try { try {
versionText = readFile(type.getVersionURL()); versionText = Shared.readFile(type.getVersionURL());
} catch (IOException e) { } catch (IOException e) {
throw new FileNotFoundException("Version file could not be downloaded."); throw new FileNotFoundException("Version file could not be downloaded.");
} }
@ -384,7 +383,7 @@ public class Server {
String versionFile = verElem.getAsJsonObject().get("url").getAsString(); String versionFile = verElem.getAsJsonObject().get("url").getAsString();
try { try {
versionText = readFile(versionFile); versionText = Shared.readFile(versionFile);
} catch (IOException e) { } catch (IOException e) {
throw new FileNotFoundException("Version file could not be downloaded."); throw new FileNotFoundException("Version file could not be downloaded.");
} }
@ -395,12 +394,12 @@ public class Server {
jsonObject = new JsonParser().parse(versionText).getAsJsonObject(); jsonObject = new JsonParser().parse(versionText).getAsJsonObject();
String jarFile = jsonObject.getAsJsonObject("downloads").getAsJsonObject("server").get("url").getAsString(); String jarFile = jsonObject.getAsJsonObject("downloads").getAsJsonObject("server").get("url").getAsString();
if (!downloadFile(jarFile, filePath)) { if (!Shared.downloadFile(jarFile, filePath)) {
throw new FileNotFoundException("Jar file could not be downloaded."); throw new FileNotFoundException("Jar file could not be downloaded.");
} }
} }
} else { } else {
if (!(file.isFile() || downloadFile(url + ver + type.getDownloadURLPart() + ver + ".jar", filePath))) { if (!(file.isFile() || Shared.downloadFile(url + ver + type.getDownloadURLPart() + ver + ".jar", filePath))) {
throw new FileNotFoundException("Jar file could not be downloaded."); throw new FileNotFoundException("Jar file could not be downloaded.");
} }
} }
@ -408,14 +407,14 @@ public class Server {
case "SpongeVanilla": case "SpongeVanilla":
type = (AdvancedServerType) this.type; type = (AdvancedServerType) this.type;
try { try {
versionText = readFile(type.getVersionURL() + this.serverVersion); versionText = Shared.readFile(type.getVersionURL() + this.serverVersion);
} catch (IOException e) { } catch (IOException e) {
throw new FileNotFoundException("Version file could not be downloaded."); throw new FileNotFoundException("Version file could not be downloaded.");
} }
newestVersion = stringBetween(versionText, type.getSrcStart(), type.getSrcEnd()); newestVersion = Shared.stringBetween(versionText, type.getSrcStart(), type.getSrcEnd());
if (!file.isFile() || !newestVersion.equals(this.getVersion(name))) { if (!file.isFile() || !newestVersion.equals(this.getVersion(name))) {
this.setVersion(name, newestVersion); this.setVersion(name, newestVersion);
if (!downloadFile(url + newestVersion + type.getDownloadURLPart() + newestVersion + ".jar", filePath)) { if (!Shared.downloadFile(url + newestVersion + type.getDownloadURLPart() + newestVersion + ".jar", filePath)) {
throw new FileNotFoundException("Jar file could not be downloaded."); throw new FileNotFoundException("Jar file could not be downloaded.");
} }
} }
@ -423,14 +422,14 @@ public class Server {
case "Bungee": case "Bungee":
type = (AdvancedServerType) this.type; type = (AdvancedServerType) this.type;
try { try {
versionText = readFile(type.getVersionURL()); versionText = Shared.readFile(type.getVersionURL());
} catch (IOException e) { } catch (IOException e) {
throw new FileNotFoundException("Version file could not be downloaded."); throw new FileNotFoundException("Version file could not be downloaded.");
} }
newestVersion = stringBetween(versionText, type.getSrcStart(), type.getSrcEnd()); newestVersion = Shared.stringBetween(versionText, type.getSrcStart(), type.getSrcEnd());
if (!file.isFile() || !newestVersion.equals(this.getVersion(name))) { if (!file.isFile() || !newestVersion.equals(this.getVersion(name))) {
this.setVersion(name, newestVersion); this.setVersion(name, newestVersion);
if (!downloadFile(url, filePath)) { if (!Shared.downloadFile(url, filePath)) {
throw new FileNotFoundException("Jar file could not be downloaded."); throw new FileNotFoundException("Jar file could not be downloaded.");
} }
} }

View File

@ -1,4 +1,4 @@
package net.knarcraft.serverlauncher.server; package net.knarcraft.minecraftserverlauncher.server;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import java.io.File; import java.io.File;

View File

@ -1,6 +1,6 @@
package net.knarcraft.serverlauncher.userinterface; package net.knarcraft.minecraftserverlauncher.userinterface;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.minecraftserverlauncher.profile.Profile;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.DefaultCaret; import javax.swing.text.DefaultCaret;

View File

@ -1,9 +1,9 @@
package net.knarcraft.serverlauncher.userinterface; package net.knarcraft.minecraftserverlauncher.userinterface;
import net.knarcraft.serverlauncher.Main; import net.knarcraft.minecraftserverlauncher.profile.Collection;
import net.knarcraft.serverlauncher.profile.Collection; import net.knarcraft.minecraftserverlauncher.Main;
import net.knarcraft.serverlauncher.server.Server; import net.knarcraft.minecraftserverlauncher.server.Server;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.minecraftserverlauncher.profile.Profile;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;

View File

@ -1,4 +1,4 @@
package net.knarcraft.serverlauncher.userinterface; package net.knarcraft.minecraftserverlauncher.userinterface;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;

View File

@ -1,8 +1,8 @@
package net.knarcraft.serverlauncher.userinterface; package net.knarcraft.minecraftserverlauncher.userinterface;
import net.knarcraft.serverlauncher.profile.Profile; import net.knarcraft.minecraftserverlauncher.profile.Profile;
import net.knarcraft.serverlauncher.server.Server; import net.knarcraft.minecraftserverlauncher.server.Server;
import net.knarcraft.serverlauncher.server.ServerType; import net.knarcraft.minecraftserverlauncher.server.ServerType;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;

View File

@ -1,6 +1,8 @@
import net.knarcraft.serverlauncher.profile.Profile; package net.knarcraft.minecraftserverlauncher;
import net.knarcraft.serverlauncher.server.ServerType;
import org.junit.jupiter.api.Test; import net.knarcraft.minecraftserverlauncher.profile.Profile;
import net.knarcraft.minecraftserverlauncher.server.ServerType;
import org.junit.Test;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import java.io.IOException; import java.io.IOException;

View File

@ -1,12 +1,14 @@
import net.knarcraft.serverlauncher.profile.Profile; package net.knarcraft.minecraftserverlauncher;
import net.knarcraft.serverlauncher.server.ServerType;
import org.junit.jupiter.api.Test; import net.knarcraft.minecraftserverlauncher.profile.Profile;
import net.knarcraft.minecraftserverlauncher.server.ServerType;
import org.junit.Test;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import static net.knarcraft.serverlauncher.Shared.stringBetween; import static net.knarcraft.minecraftserverlauncher.Shared.stringBetween;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.Assert.assertEquals;
public class Tests { public class Tests {
@Test @Test