mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-10 14:26:45 +00:00
Maven and file access
- Server config file is now accessed through the class loader - Maven outputs server.jar, moves dependencys to adjacent /libs, and plugins to adjacent /plugins
This commit is contained in:
parent
c23ee0dc86
commit
59e3e9430e
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,3 +13,5 @@ plugins/*.jar
|
||||
save.json
|
||||
Server/Server.iml
|
||||
target/*
|
||||
Server/Server.iml
|
||||
Server/src/main/java/META-INF/MANIFEST.MF
|
||||
|
@ -6,9 +6,6 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/${parent.project.basedir}/ServerTarget" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/ServerTarget" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
@ -13,10 +13,10 @@
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>/</directory>
|
||||
<directory>../Server/src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>../config.properties</include>
|
||||
<include>config.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
@ -30,6 +30,23 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>../target/libs</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
@ -38,6 +55,8 @@
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>net.simon987.server.Main</mainClass>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>libs/</classpathPrefix>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
|
@ -40,7 +40,7 @@ public class GameServer implements Runnable {
|
||||
|
||||
public GameServer() {
|
||||
|
||||
this.config = new ServerConfiguration(new File("config.properties"));
|
||||
this.config = new ServerConfiguration("config.properties");
|
||||
|
||||
gameUniverse = new GameUniverse(config);
|
||||
pluginManager = new PluginManager();
|
||||
|
@ -12,8 +12,7 @@ public class Main {
|
||||
|
||||
|
||||
LogManager.initialize();
|
||||
ServerConfiguration config = new ServerConfiguration(new File("config.properties"));
|
||||
|
||||
ServerConfiguration config = new ServerConfiguration("config.properties");
|
||||
//Load
|
||||
GameServer.INSTANCE.getGameUniverse().load(new File("save.json"));
|
||||
|
||||
|
@ -6,6 +6,7 @@ import net.simon987.server.logging.LogManager;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@ -18,11 +19,11 @@ public class ServerConfiguration {
|
||||
*/
|
||||
private Properties properties;
|
||||
|
||||
public ServerConfiguration(File file) {
|
||||
public ServerConfiguration(String file) {
|
||||
try {
|
||||
properties = new Properties();
|
||||
|
||||
properties.load(new FileInputStream(file));
|
||||
InputStream is = ServerConfiguration.class.getClassLoader().getResourceAsStream("config.properties");
|
||||
properties.load(is);
|
||||
|
||||
} catch (IOException e) {
|
||||
LogManager.LOGGER.severe("Problem loading server configuration: " + e.getMessage());
|
||||
|
Loading…
x
Reference in New Issue
Block a user