Skip to content

Commit 3906807

Browse files
authored
Merge pull request #12 from MovingBlocks/release
Bump versions and support running on localhost only
2 parents 9839f87 + 9abf8a6 commit 3906807

5 files changed

Lines changed: 59 additions & 27 deletions

File tree

build.gradle

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
plugins {
2-
id "org.owasp.dependencycheck" version "5.0.0-M3.1"
2+
id "org.owasp.dependencycheck" version "7.1.0.1"
33
id 'java'
44
id 'application'
55
id 'eclipse'
66
id 'pmd'
77
id 'checkstyle'
8-
id 'com.github.spotbugs' version '4.5.0'
8+
id 'com.github.spotbugs' version '4.7.1'
99
}
1010

1111
apply from: 'config/gradle/versioning.gradle'
@@ -15,6 +15,9 @@ applicationName = "meta-server"
1515

1616
group = 'org.terasology.web'
1717

18+
targetCompatibility = '11'
19+
sourceCompatibility = '11'
20+
1821
repositories {
1922
mavenCentral()
2023

@@ -26,7 +29,7 @@ repositories {
2629
}
2730

2831
ext {
29-
jettyVersion = '9.4.6.v20170531'
32+
jettyVersion = '9.4.48.v20220622'
3033
}
3134

3235
def codeMetricsDir = "${buildDir}/codeMetrics"
@@ -42,33 +45,35 @@ dependencies {
4245
implementation 'javax.annotation:javax.annotation-api:1.3.2'
4346
implementation 'com.google.code.findbugs:jsr305:3.0.0'
4447

45-
implementation 'org.glassfish.jersey.containers:jersey-container-jetty-servlet:2.22.1'
46-
implementation 'org.glassfish.jersey.ext:jersey-mvc-freemarker:2.22.1'
48+
implementation 'com.sun.xml.bind:jaxb-impl:2.3.3'
49+
implementation group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.1.1'
4750

48-
implementation 'com.google.code.gson:gson:2.4'
49-
implementation 'com.google.guava:guava:18.0'
51+
implementation 'org.glassfish.jersey.containers:jersey-container-jetty-servlet:2.25'
52+
implementation 'org.glassfish.jersey.ext:jersey-mvc-freemarker:2.25'
5053

51-
implementation 'org.jooq:jooq:3.7.0'
52-
implementation 'org.postgresql:postgresql:9.4-1205-jdbc42'
54+
implementation 'com.google.code.gson:gson:2.9.1'
55+
implementation 'com.google.guava:guava:31.1-jre'
5356

54-
implementation 'com.squareup.retrofit:retrofit:1.9.0'
57+
implementation 'org.jooq:jooq:3.14.16'
58+
implementation 'org.postgresql:postgresql:42.4.1'
5559

56-
implementation 'org.slf4j:slf4j-api:1.7.13'
60+
implementation 'com.squareup.retrofit:retrofit:1.9.0'
5761

58-
implementation 'com.zaxxer:HikariCP:2.4.1'
62+
implementation 'com.zaxxer:HikariCP:5.0.1'
5963

6064
implementation 'org.terasology:gestalt-module:4.1.2'
6165

62-
testImplementation 'org.jsoup:jsoup:1.8.3'
63-
testImplementation 'com.jcabi:jcabi-w3c:1.3'
64-
testImplementation 'com.jcabi:jcabi-matchers:1.4'
65-
testImplementation 'junit:junit:4.12'
66+
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
67+
68+
testImplementation 'org.jsoup:jsoup:1.15.2'
69+
testImplementation 'com.jcabi:jcabi-w3c:1.4.0'
70+
testImplementation 'com.jcabi:jcabi-matchers:1.5.3'
71+
testImplementation 'junit:junit:4.13.2'
6672
testImplementation 'com.h2database:h2:1.4.190'
6773

68-
runtimeOnly group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.3'
6974

70-
pmd 'net.sourceforge.pmd:pmd-core:6.27.0'
71-
pmd 'net.sourceforge.pmd:pmd-java:6.27.0'
75+
pmd 'net.sourceforge.pmd:pmd-core:6.48.0'
76+
pmd 'net.sourceforge.pmd:pmd-java:6.48.0'
7277

7378
codeMetrics group: 'org.terasology.config', name: 'codemetrics', version: '1.3.2', ext: 'zip'
7479
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#Mon Apr 20 18:44:42 CEST 2015
2-
version=2.7.1-SNAPSHOT
2+
version=2.8.0-SNAPSHOT
33
versioneye.projectkey=maven2_master_server_1
44
versioneye.projectid=55352d6edc39815abf0007ad

src/main/java/org/terasology/web/JettyMain.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.terasology.web;
1818

19+
import java.net.InetSocketAddress;
1920
import java.net.URI;
2021
import java.nio.file.Path;
2122
import java.nio.file.Paths;
@@ -77,6 +78,14 @@ public static void main(String[] args) throws Exception {
7778
}
7879
Integer port = Integer.valueOf(portEnv);
7980

81+
String localhostOnlyEnv = System.getenv("LOCALHOST_ONLY");
82+
Boolean localhostOnly = true;
83+
if (localhostOnlyEnv != null) {
84+
localhostOnly = Boolean.valueOf(localhostOnlyEnv);
85+
} else {
86+
logger.warn("Environment variable 'LOCALHOST_ONLY' not defined - using default {}", localhostOnly);
87+
}
88+
8089
String dbEnv = System.getenv("DATABASE_URL");
8190
if (dbEnv == null) {
8291
logger.error("Environment variable 'DATABASE_URL' not defined!");
@@ -139,6 +148,7 @@ public static void main(String[] args) throws Exception {
139148
ServerListModel serverListModel = new ServerListModelImpl(dataBase, "servers", secret);
140149

141150
Server server = createServer(port.intValue(),
151+
localhostOnly,
142152
new AboutServlet(),
143153
new ServerServlet(serverListModel), // the server list servlet
144154
new ModuleServlet(moduleListModel)); // the module list servlet
@@ -152,8 +162,15 @@ public static void main(String[] args) throws Exception {
152162
}
153163
}
154164

155-
public static Server createServer(int port, Object... servlets) throws Exception {
156-
Server server = new Server(port);
165+
public static Server createServer(int port, boolean localOnly, Object... servlets) throws Exception {
166+
167+
Server server;
168+
169+
if (localOnly) {
170+
server = new Server(new InetSocketAddress("localhost", port));
171+
} else {
172+
server = new Server(port);
173+
}
157174

158175
ResourceHandler logFileResourceHandler = new ResourceHandler();
159176
logFileResourceHandler.setDirectoriesListed(true);

src/main/java/org/terasology/web/model/ModuleListModelImpl.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.terasology.web.artifactory.ArtifactInfo;
5050
import org.terasology.web.artifactory.ArtifactRepository;
5151

52+
import com.google.common.collect.ImmutableList;
5253
import com.google.common.io.Files;
5354

5455
/**
@@ -69,6 +70,8 @@ public class ModuleListModelImpl implements ModuleListModel {
6970

7071
private final Path cacheFolder;
7172

73+
private final List<String> ignoredModules = ImmutableList.of("engine", "engine-tests");
74+
7275
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
7376

7477
public ModuleListModelImpl(Path cacheFolder) {
@@ -93,16 +96,22 @@ public void addRepository(ArtifactRepository repo) {
9396
public void updateAllModules() {
9497
for (ArtifactRepository repo : repositories) {
9598
for (String moduleName : repo.getModuleNames()) {
96-
try {
97-
repo.updateModule(moduleName.toString());
98-
updateModule(repo, moduleName);
99-
} catch (IOException e) {
100-
logger.warn("Could not update module {}", moduleName);
99+
if (isRelevant(moduleName)) {
100+
try {
101+
repo.updateModule(moduleName);
102+
updateModule(repo, moduleName);
103+
} catch (IOException e) {
104+
logger.warn("Could not update module {}", moduleName);
105+
}
101106
}
102107
}
103108
}
104109
}
105110

111+
private boolean isRelevant(String moduleName) {
112+
return !ignoredModules.contains(moduleName);
113+
}
114+
106115
@Override
107116
public void updateModule(Name moduleName) {
108117

src/test/java/org/terasology/master/WebServerBasedTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public static void setup() throws Exception {
9595
ServerListModel serverListModel = new ServerListModelImpl(dataBase, SERVER_TABLE, secret);
9696

9797
webServer = JettyMain.createServer(PORT,
98+
true,
9899
new AboutServlet(),
99100
new ServerServlet(serverListModel), // the server list servlet
100101
new ModuleServlet(moduleListModel)); // the module list servlet

0 commit comments

Comments
 (0)