Skip to content

Commit 33a0f28

Browse files
committed
release: version 5.1.0
2 parents ed97ec6 + 36fc91b commit 33a0f28

File tree

58 files changed

+973
-456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+973
-456
lines changed

build-logic/src/main/kotlin/terasology-module.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ configure<SourceSetContainer> {
3737

3838
configurations {
3939
all {
40-
resolutionStrategy.preferProjectModules()
40+
resolutionStrategy {
41+
preferProjectModules()
42+
// always pick reflections fork
43+
dependencySubstitution {
44+
@Suppress("UnstableApiUsage")
45+
substitute(module("org.reflections:reflections")).using(module("org.terasology:reflections:0.9.12-MB"))
46+
}
47+
}
4148
}
4249
}
4350

config/groovy/common.groovy

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,20 @@ class common {
124124
} else {
125125
itemsRetrieved << itemName
126126
def targetUrl = "https://github.com/${githubTargetHome}/${itemName}"
127-
if (!isUrlValid(targetUrl)) {
128-
println "Can't retrieve $itemType from $targetUrl - URL appears invalid. Typo? Not created yet?"
127+
try {
128+
println "Retrieving $itemType $itemName from $targetUrl"
129+
if (githubTargetHome != githubDefaultHome) {
130+
println "Doing a retrieve from a custom remote: $githubTargetHome - will name it as such plus add the $githubDefaultHome remote as '$defaultRemote'"
131+
Grgit.clone dir: targetDir, uri: targetUrl, remote: githubTargetHome
132+
println "Primary clone operation complete, about to add the '$defaultRemote' remote for the $githubDefaultHome org address"
133+
addRemote(itemName, defaultRemote, "https://github.com/${githubDefaultHome}/${itemName}")
134+
} else {
135+
Grgit.clone dir: targetDir, uri: targetUrl
136+
}
137+
} catch (GrgitException exception) {
138+
println color("Unable to clone $itemName, Skipping: ${exception.getMessage()}", Ansi.RED)
129139
return
130140
}
131-
println "Retrieving $itemType $itemName from $targetUrl"
132-
if (githubTargetHome != githubDefaultHome) {
133-
println "Doing a retrieve from a custom remote: $githubTargetHome - will name it as such plus add the $githubDefaultHome remote as '$defaultRemote'"
134-
Grgit.clone dir: targetDir, uri: targetUrl, remote: githubTargetHome
135-
println "Primary clone operation complete, about to add the '$defaultRemote' remote for the $githubDefaultHome org address"
136-
addRemote(itemName, defaultRemote, "https://github.com/${githubDefaultHome}/${itemName}")
137-
} else {
138-
Grgit.clone dir: targetDir, uri: targetUrl
139-
}
140141

141142
// This step allows the item type to check the newly cloned item and add in extra template stuff
142143
itemTypeScript.copyInTemplateFiles(targetDir)
@@ -222,8 +223,8 @@ class common {
222223
def targetUrl = remotes.find {
223224
it.name == defaultRemote
224225
}?.url
225-
if (targetUrl == null || !isUrlValid(targetUrl)) {
226-
println color("While updating $itemName found its '$defaultRemote' remote invalid or its URL unresponsive: $targetUrl", Ansi.RED)
226+
if (targetUrl == null) {
227+
println color("While updating $itemName remote `$defaultRemote` is not found.", Ansi.RED)
227228
return
228229
}
229230

engine-tests/src/main/java/org/terasology/engine/Environment.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
import java.util.Set;
2020

2121
/**
22-
* Setup an empty Terasology environment
23-
*
22+
* Set up an empty Terasology environment.
23+
* <p>
24+
* Not for use outside {@code engine-tests}. Modules should use ModuleTestingEnvironment.
2425
*/
25-
public class Environment {
26+
class Environment {
2627

2728
private static final Logger logger = LoggerFactory.getLogger(Environment.class);
2829

engine-tests/src/main/java/org/terasology/engine/HeadlessEnvironment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
/**
102102
* Setup a headless ( = no graphics ) environment.
103103
* Based on TerasologyTestingEnvironment code.
104-
*
104+
* <p>
105+
* <b>Deprecated</b> for use outside of {@code engine-tests}; modules should use ModuleTestingEnvironment.
105106
*/
106107
public class HeadlessEnvironment extends Environment {
107108

engine-tests/src/main/java/org/terasology/engine/WorldProvidingHeadlessEnvironment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33
package org.terasology.engine;
44

5-
import org.terasology.gestalt.naming.Name;
65
import org.terasology.engine.registry.CoreRegistry;
76
import org.terasology.engine.world.BlockEntityRegistry;
87
import org.terasology.engine.world.WorldProvider;
@@ -12,10 +11,14 @@
1211
import org.terasology.engine.world.internal.EntityAwareWorldProvider;
1312
import org.terasology.engine.world.internal.WorldProviderCore;
1413
import org.terasology.engine.world.internal.WorldProviderWrapper;
14+
import org.terasology.gestalt.naming.Name;
1515

1616
/**
1717
* Environment with a MapWorldProvider and BlockManager. Useful to get headless environment with a generated world.
18+
*
19+
* @deprecated Use ModuleTestingEnvironment.
1820
*/
21+
@Deprecated
1922
public class WorldProvidingHeadlessEnvironment extends HeadlessEnvironment {
2023

2124
public WorldProvidingHeadlessEnvironment(Name... modules) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id" : "unittest",
3-
"version" : "5.0.0",
3+
"version" : "5.1.0",
44
"displayName" : "Terasology Engine Test",
55
"description" : "Engine unit test content"
66
}

engine-tests/src/test/java/org/terasology/engine/core/module/ClasspathCompromisingModuleFactoryTest.java

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
package org.terasology.engine.core.module;
55

6+
import org.junit.jupiter.api.BeforeEach;
67
import org.junit.jupiter.api.Disabled;
78
import org.junit.jupiter.api.Test;
89
import org.terasology.gestalt.module.Module;
9-
import org.terasology.gestalt.module.ModuleFactory;
1010
import org.terasology.gestalt.module.ModuleMetadata;
1111
import org.terasology.gestalt.module.sandbox.API;
1212
import org.terasology.gestalt.naming.Name;
@@ -15,17 +15,29 @@
1515

1616
import java.io.File;
1717
import java.io.IOException;
18+
import java.net.MalformedURLException;
19+
import java.net.URL;
20+
import java.nio.file.Path;
21+
import java.nio.file.Paths;
1822

23+
import static com.google.common.truth.Truth8.assertThat;
1924
import static org.junit.jupiter.api.Assertions.assertFalse;
2025
import static org.junit.jupiter.api.Assertions.assertTrue;
2126

2227
public class ClasspathCompromisingModuleFactoryTest {
2328
static final Class<?> someClassOutsideTheModule = ClasspathCompromisingModuleFactory.class;
29+
static final String METADATA_NAME = "module.json";
30+
31+
ClasspathCompromisingModuleFactory factory;
32+
33+
@BeforeEach
34+
public void newFactory() {
35+
factory = new ClasspathCompromisingModuleFactory();
36+
factory.setDefaultLibsSubpath("build/libs");
37+
}
2438

2539
@Test
2640
public void directoryModuleContainsClass() {
27-
ModuleFactory factory = new ClasspathCompromisingModuleFactory();
28-
2941
// This test assumes that the unittest module is under the current working directory (`engine-test/`)
3042
File engineTestDirectory = new File(System.getProperty("user.dir", "."));
3143
ModuleMetadata metadata = new ModuleMetadata(new Name("unittest"), new Version("1.0.0"));
@@ -42,8 +54,6 @@ public void directoryModuleContainsClass() {
4254
@Test
4355
@Disabled("TODO: need a jar module containing classes")
4456
public void archiveModuleContainsClass() throws IOException {
45-
ModuleFactory factory = new ClasspathCompromisingModuleFactory();
46-
4757
Module module = factory.createArchiveModule(new File("FIXME.jar"));
4858

4959
Class<?> someClassInTheModule = module.getModuleManifest().getTypesAnnotatedWith(API.class).iterator().next();
@@ -60,4 +70,31 @@ public void directoryModuleContainsClassLoadedFromJar() {
6070
// - m/build/libs/foo.jar
6171
// load m as directory module while foo.jar is on classpath
6272
}
73+
74+
@Test
75+
public void canGetPathFromJarResource() throws MalformedURLException {
76+
// A jar file on the classpath but not in a local build directory.
77+
URL jarUrl = new URL("jar:file:/example/Terasology/cachedModules/CoreAssets-2.3.0-SNAPSHOT.jar!/module.json");
78+
Path expectedPath = Paths.get("/example/Terasology/cachedModules/CoreAssets-2.3.0-SNAPSHOT.jar");
79+
80+
assertThat(factory.canonicalModuleLocation(METADATA_NAME, jarUrl)).isEqualTo(expectedPath);
81+
}
82+
83+
@Test
84+
public void canGetPathFromLocalJarBuild() throws MalformedURLException {
85+
// A jar file on the classpath that is a build directory in a local development workspace
86+
URL jarUrl = new URL("jar:file:/example/Terasology/modules/CoreAssets/build/libs/CoreAssets-2.3.0-SNAPSHOT.jar!/module.json");
87+
Path expectedPath = Paths.get("/example/Terasology/modules/CoreAssets");
88+
89+
assertThat(factory.canonicalModuleLocation(METADATA_NAME, jarUrl)).isEqualTo(expectedPath);
90+
}
91+
92+
@Test
93+
public void canGetPathFromFilesystemResource() throws MalformedURLException {
94+
// A directory on the classpath that is a build directory in a local development workspace
95+
URL fileUrl = new URL("file:/example/Terasology/modules/Health/build/classes/module.json");
96+
Path expectedPath = Paths.get("/example/Terasology/modules/Health");
97+
98+
assertThat(factory.canonicalModuleLocation(METADATA_NAME, fileUrl)).isEqualTo(expectedPath);
99+
}
63100
}

engine/build.gradle

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,24 @@ configurations {
5151
}
5252
}
5353

54+
configurations.all {
55+
resolutionStrategy {
56+
// always pick reflections fork
57+
dependencySubstitution {
58+
substitute(module("org.reflections:reflections")).using(module("org.terasology:reflections:0.9.12-MB"))
59+
}
60+
}
61+
}
62+
5463
// Primary dependencies definition
5564
dependencies {
5665
// Storage and networking
5766
api group: 'com.google.guava', name: 'guava', version: '30.1-jre'
5867
api group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
5968
api group: 'net.sf.trove4j', name: 'trove4j', version: '3.0.3'
60-
implementation group: 'io.netty', name: 'netty-all', version: '4.1.53.Final'
69+
implementation group: 'io.netty', name: 'netty-all', version: '4.1.65.Final'
6170
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '2.6.1'
71+
implementation group: 'org.lz4', name: 'lz4-java', version: '1.8.0'
6272
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
6373
// Javax for protobuf due to @Generated - needed on Java 9 or newer Javas
6474
// TODO: Can likely replace with protobuf Gradle task and omit the generated source files instead

engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.terasology.engine.core.subsystem.common.ThreadManagerSubsystem;
3030
import org.terasology.engine.core.subsystem.common.TimeSubsystem;
3131
import org.terasology.engine.core.subsystem.common.WorldGenerationSubsystem;
32-
import org.terasology.engine.core.subsystem.rendering.ModuleRenderingSubsystem;
3332
import org.terasology.engine.entitySystem.prefab.Prefab;
3433
import org.terasology.engine.entitySystem.prefab.internal.PojoPrefab;
3534
import org.terasology.engine.i18n.I18nSubsystem;
@@ -175,7 +174,6 @@ public TerasologyEngine(TimeSubsystem timeSubsystem, Collection<EngineSubsystem>
175174
this.allSubsystems.add(new GameSubsystem());
176175
this.allSubsystems.add(new I18nSubsystem());
177176
this.allSubsystems.add(new TelemetrySubSystem());
178-
this.allSubsystems.add(new ModuleRenderingSubsystem());
179177

180178
// add all subsystem as engine module part. (needs for ECS classes loaded from external subsystems)
181179
allSubsystems.stream().map(Object::getClass).forEach(this::addToClassesOnClasspathsToAddToEngine);
@@ -489,7 +487,6 @@ public boolean tick() {
489487
}
490488

491489
Iterator<Float> updateCycles = timeSubsystem.getEngineTime().tick();
492-
CoreRegistry.setContext(currentState.getContext());
493490
rootContext.get(NetworkSystem.class).setContext(currentState.getContext());
494491

495492
for (EngineSubsystem subsystem : allSubsystems) {
@@ -586,6 +583,7 @@ private void switchState(GameState newState) {
586583
if (currentState != null) {
587584
currentState.dispose();
588585
}
586+
CoreRegistry.setContext(newState.getContext());
589587
currentState = newState;
590588
LoggingContext.setGameState(newState);
591589
newState.init(this);

0 commit comments

Comments
 (0)