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

chore: migrate to gestalt v7—fork 🅰, keep subsystems separate #4622

Merged
merged 82 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
e55b7f0
feature: migrate to gestaltv7
pollend Mar 21, 2021
f9ce52f
bugfix: correct copy strategy
pollend Mar 28, 2021
46c29ee
chore: remove copy strategy
pollend Mar 28, 2021
5504449
fix formatting
pollend Mar 28, 2021
9afe704
refactor(handleSwitchToGameEnvironment): these are all one copy strategy
keturn Apr 1, 2021
850ee40
build: no dependency on gestalt-entity-system yet
keturn Apr 1, 2021
911110a
Merge branch 'nui-gestalt-separation' into feature/migrate-gestalt-v7
keturn Apr 2, 2021
d9af0ba
chore(ComponentSystem): debugging logs
keturn Apr 2, 2021
0a175af
chore(UISkinWithUrn): update for gestalt 7
keturn Apr 2, 2021
8e26159
chore: revert move of jmh sources
keturn Apr 2, 2021
7b1bd17
fixup! chore: revert move of jmh sources
keturn Apr 2, 2021
cba8ef5
core(EntitySystemSetup): null checking
keturn Apr 2, 2021
3986c4d
refactor(ModuleManager): restore some organization from the develop b…
keturn Apr 2, 2021
b874418
test: reduce duplicate exception logs and wrapping
keturn Apr 2, 2021
bfb1a8e
test: add mockito-inline to empower mockito to do more invasive things
keturn Apr 2, 2021
6412aab
test(ModuleEnvironmentTest): assert, don't `assume`!
keturn Apr 2, 2021
a7e2fb3
test(TerasologyTestingEnvironment): avoid NPE on tearDown (the result…
keturn Apr 2, 2021
f3711c3
test(InputSystemTest): do not always include TestEventButton in the r…
keturn Apr 2, 2021
442d2fd
feat(ModuleManager): add method for creating an environment with reso…
keturn Apr 2, 2021
31715d2
test(BindsSubsystemTest): update for gestalt-v7
keturn Apr 2, 2021
1c48c86
test(TypeSerializerTest): lint
keturn Apr 2, 2021
42ffb8e
chore: bump version to 4.4.1-SNAPSHOT
keturn Apr 2, 2021
2f9d4af
Merge remote-tracking branch 'origin/nui-gestalt-separation' into fea…
keturn Apr 2, 2021
20546f1
fix(ModuleManager): loosen auto-generated dependency version
keturn Apr 2, 2021
94e1e41
Merge remote-tracking branch 'origin/develop' into feature/migrate-ge…
keturn Apr 9, 2021
1a80bcf
build: upgrade build-logic to gestalt-7
keturn Apr 10, 2021
b787951
build: add google repo to terasology-repositories build logic
keturn Apr 10, 2021
d353031
fix(DiscordRPC): null check in preShutdown
keturn Apr 10, 2021
e3d8419
fix(ModuleManager): include subsystems in the reflections of the engi…
keturn Apr 10, 2021
b0afa69
fix(ModuleManager): add subsystems and NUI to engine module
keturn Apr 10, 2021
26c4457
chore(NUIManager): log when widgets are not correctly registered
keturn Apr 10, 2021
3220811
test: correct expected/actual argument order
keturn Apr 11, 2021
9204eab
build: factor out reflections manifest `cacheReflections` task [WIP]
keturn Apr 11, 2021
05bbdf5
test: more assertions for pesky deserialization tests
keturn Apr 14, 2021
540161a
test(ModuleEnvironmentTest): initialize TypeRegistry list of permitte…
keturn Apr 14, 2021
1c583af
test(TypeSerializerTest): add json variant of test
keturn Apr 14, 2021
8c5f4bd
test: tidy
keturn Apr 14, 2021
afe6512
test(ModuleEnvironmentSandbox): initial sketch of test cases
keturn Apr 14, 2021
ff14cd1
test(ModuleEnvironmentSandbox): fix names used to request classes
keturn Apr 14, 2021
1c17362
fix(ModuleManager): engine module claims sources of all active subsys…
keturn Apr 15, 2021
94fa9a2
chore: use WidgetLibrary from NUI instead of internal copy
keturn Apr 15, 2021
8192ad3
test: fix ExampleInterface import
keturn Apr 15, 2021
3a7ab90
Merge remote-tracking branch 'origin/develop' into feature/migrate-ge…
keturn Apr 15, 2021
968d226
test: always add NUI classes to engine
keturn Apr 15, 2021
7d0f9ec
Merge remote-tracking branch 'origin/develop' into feature/migrate-ge…
keturn Apr 15, 2021
8350ebb
revert b0afa69be334b8d8b826aaf30bf281ea3b4d750f
keturn Apr 15, 2021
b42a539
test(ModuleEnvironmentTest): don't always try to build an environment…
keturn Apr 16, 2021
d5c74cc
fix(ModuleManager): re-implement classpath modules for tests under ge…
keturn Apr 17, 2021
8aef6cc
fix(ClasspathCompromisingModuleFactory): allow code from either class…
keturn Apr 17, 2021
911b2bf
bugfix: remove DirectoryFileSource requirment for gameplay templates
pollend Apr 17, 2021
7c9e4d6
test(TranslationFormat): re-implement with FileReference instead of Path
keturn Apr 18, 2021
a750f39
Merge remote-tracking branch 'origin/feature/migrate-gestalt-v7.a' in…
keturn Apr 18, 2021
d71124e
Merge remote-tracking branch 'origin/develop' into feature/migrate-ge…
keturn Apr 20, 2021
c725b45
Merge remote-tracking branch 'origin/develop' into feature/migrate-ge…
keturn Apr 22, 2021
6bacddc
test(TypeSerializerTest): clean out some commented and out-of-scope code
keturn Apr 23, 2021
599f71d
chore: remove commented code
keturn Apr 23, 2021
a3130fa
chore(ModuleDetailsScreen): switch from versionRange to more flexible…
keturn Apr 23, 2021
3763ae3
Merge remote-tracking branch 'origin/develop' into feature/migrate-ge…
keturn Apr 23, 2021
2705192
doc: explain how ClasspathCompromisingModuleFactory is different and …
keturn Apr 23, 2021
a0ab333
test(ClasspathCompromisingModuleFactoryTest): document the assumption…
keturn Apr 23, 2021
5dd89ee
fix(ClientConnectionHandler): update for new ModuleManager
keturn Apr 23, 2021
7f31a7b
chore(EnvironmentSwitchHandler): replace clever use of reflections wi…
keturn Apr 24, 2021
30d4ac2
chore(GLSLMaterial): tidy
keturn Apr 24, 2021
67db33e
chore(Audio): remove commented code
keturn Apr 24, 2021
f60f2a0
fix(ModuleInstaller): update for new ModuleManager
keturn Apr 24, 2021
f952993
chore: tidy whitespace, commented code
keturn Apr 24, 2021
5026e55
fix: revert change to SubtypeLayoutBuilder
keturn Apr 24, 2021
517a3d1
fix(TerasologyEngine): re-instate asset reloading
keturn Apr 24, 2021
9a4312c
test: fix (expected, actual) order of assertEquals
keturn Apr 24, 2021
a0a4da2
test: tag ModuleEnvironmentTest as being in the "integrationTest" cat…
keturn Apr 24, 2021
fcd4bf4
chore: move engine-module assets under org/terasology/engine
keturn Apr 24, 2021
077f288
build: upgrade to gestalt 7.1.0-SNAPSHOT from 7.0.6
keturn Apr 25, 2021
2b54db5
build: disable build-time cacheReflections in a more consistent way
keturn Apr 26, 2021
0bd23a7
build: remove commented-out uses of reflections-cache
keturn Apr 27, 2021
7c6a679
fix(ComponentFieldMetadata): do not pass null to CopyStrategy
keturn Apr 28, 2021
de35020
fix(ExternalApi): remove some over-broad package entries
keturn Apr 28, 2021
9cffcbb
bugfix: assetTypeManager becomes unavalible becomes of RegisterMods a…
pollend Apr 28, 2021
1e9a36c
Revert "bugfix: assetTypeManager becomes unavalible becomes of Regist…
pollend Apr 28, 2021
f52ebb9
chore(ModuleManager): let dependency use default maxVersion
keturn Apr 29, 2021
5435097
test: move to match package directory
keturn Apr 29, 2021
b3df7c3
test: move stub components in to org.terasology.unittest module.
keturn May 2, 2021
aae87b3
Merge remote-tracking branch 'origin/develop' into feature/migrate-ge…
keturn May 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {

repositories {
mavenCentral()
google() // gestalt uses an annotation package by Google

maven {
name = "Terasology Artifactory"
Expand All @@ -21,10 +22,11 @@ repositories {
dependencies {
// Needed for caching reflected data during builds
implementation("org.terasology:reflections:0.9.12-MB")
implementation("org.javassist:javassist:3.27.0-GA")
implementation("dom4j:dom4j:1.6.1")

// for inspecting modules
implementation("org.terasology:gestalt-module:5.1.5")
implementation("org.terasology.gestalt:gestalt-module:7.0.6-SNAPSHOT")

api(kotlin("test"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package org.terasology.gradology

import org.gradle.api.Project
import org.terasology.module.DependencyInfo
import org.terasology.module.ModuleMetadata
import org.terasology.module.ModuleMetadataJsonAdapter
import org.terasology.naming.Version
import org.terasology.gestalt.module.ModuleMetadata
import org.terasology.gestalt.module.ModuleMetadataJsonAdapter
import org.terasology.gestalt.module.dependencyresolution.DependencyInfo
import org.terasology.gestalt.naming.Version
import java.io.File


Expand Down
42 changes: 42 additions & 0 deletions build-logic/src/main/kotlin/reflections-manifest.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

import org.reflections.Reflections
import org.reflections.scanners.SubTypesScanner
import org.reflections.scanners.TypeAnnotationsScanner
import org.reflections.serializers.JsonSerializer
import org.reflections.util.ConfigurationBuilder
import java.net.URLClassLoader

tasks.register("cacheReflections") {
description = "Caches reflection output to make regular startup faster. May go stale and need cleanup at times."

val sourceSets = project.convention.getPlugin(JavaPluginConvention::class.java).sourceSets
val mainSourceSet: SourceSet = sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]

inputs.files(mainSourceSet.output.classesDirs)
dependsOn(tasks.named("classes"))
outputs.upToDateWhen { tasks.named("classes").get().state.upToDate }

// TODO: output to the task's own build directory, because putting things in the
// classes directory confuses gradle caching.
val manifestFile = File(mainSourceSet.output.classesDirs.first(), "manifest.json")
outputs.file(manifestFile)

doLast {
val classPaths = mainSourceSet.compileClasspath.map { it.toURI().toURL() }
val classLoader = URLClassLoader(classPaths.toTypedArray())
try {
val reflections = Reflections(
ConfigurationBuilder()
.setSerializer(JsonSerializer())
.addClassLoader(classLoader)
// .filterInputsBy(FilterBuilder.parsePackages("+org"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out / what would it do if commented in?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was from some attempt to reduce the amount of time this was taking by restricting which packages it considers.

Not that including all org packages (but not com, etc) makes much sense.

.addUrls(inputs.files.map { it.toURI().toURL() })
.setScanners(TypeAnnotationsScanner(), SubTypesScanner(false)))
reflections.save(manifestFile.toString())
} catch (e: java.net.MalformedURLException) {
logger.error("Cannot parse input to url", e)
}
}
}
33 changes: 0 additions & 33 deletions build-logic/src/main/kotlin/terasology-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

import org.gradle.plugins.ide.eclipse.model.EclipseModel
import org.gradle.plugins.ide.idea.model.IdeaModel
import org.reflections.Reflections
import org.reflections.scanners.SubTypesScanner
import org.reflections.scanners.TypeAnnotationsScanner
import org.reflections.util.ConfigurationBuilder
import org.reflections.util.FilterBuilder
import org.terasology.gradology.ModuleMetadataForGradle

plugins {
Expand Down Expand Up @@ -121,32 +116,6 @@ tasks.register("createSkeleton") {
val mainSourceSet: SourceSet = sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]


tasks.register("cacheReflections") {
description = "Caches reflection output to make regular startup faster. May go stale and need cleanup at times."
inputs.files(mainSourceSet.output.classesDirs)
outputs.file(File(mainSourceSet.output.classesDirs.first(), "reflections.cache"))
dependsOn(tasks.named("classes"))

outputs.upToDateWhen { tasks.named("classes").get().state.upToDate }

doFirst {
try {
val reflections = Reflections(ConfigurationBuilder()
.filterInputsBy(FilterBuilder.parsePackages("+org"))
.addUrls(inputs.getFiles().getSingleFile().toURI().toURL())
.setScanners(TypeAnnotationsScanner(), SubTypesScanner()))
reflections.save(outputs.getFiles().getAsPath())
} catch (e: java.net.MalformedURLException) {
logger.error("Cannot parse input to url", e)
}
}
}

tasks.register<Delete>("cleanReflections") {
description = "Cleans the reflection cache. Useful in cases where it has gone stale and needs regeneration."
delete(tasks.getByName("cacheReflections").outputs.files)
}

// This task syncs everything in the assets dir into the output dir, used when jarring the module
tasks.register<Sync>("syncAssets") {
from("assets")
Expand All @@ -166,7 +135,6 @@ tasks.register<Sync>("syncDeltas") {
// Instructions for packaging a jar file - is a manifest even needed for modules?
tasks.named("jar") {
// Make sure the assets directory is included
dependsOn("cacheReflections")
dependsOn("syncAssets")
dependsOn("syncOverrides")
dependsOn("syncDeltas")
Expand All @@ -179,7 +147,6 @@ tasks.named("jar") {
}
}

finalizedBy("cleanReflections")
}

tasks.named<Test>("test") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ repositories {
}
}

google {
// gestalt uses an annotation library from Google
content {
// (This is an optimization so gradle doesn't try to find our hundreds of modules here.)
excludeGroupByRegex("""org\.terasology(\..+)?""")
}
}

// MovingBlocks Artifactory instance for libs not readily available elsewhere plus our own libs
maven {
val repoViaEnv = System.getenv()["RESOLUTION_REPO"]
Expand Down
18 changes: 3 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
buildscript {
repositories {
mavenCentral()
google()
gradlePluginPortal()

maven {
Expand All @@ -16,10 +17,6 @@ buildscript {
}

dependencies {
// Needed for caching reflected data during builds
classpath 'org.terasology:reflections:0.9.12-MB'
classpath 'dom4j:dom4j:1.6.1'

//Spotbugs
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.0.0"

Expand All @@ -43,6 +40,8 @@ plugins {
id "idea"
// For the "Build and run using: Intellij IDEA | Gradle" switch
id "org.jetbrains.gradle.plugin.idea-ext" version "1.0"

id("terasology-repositories")
}


Expand Down Expand Up @@ -71,17 +70,6 @@ ext {
LwjglVersion = '3.2.3'
}

// Declare remote repositories we're interested in - library files will be fetched from here
repositories {
mavenCentral()

// MovingBlocks Artifactory instance for libs not readily available elsewhere plus our own libs
maven {
name "Terasology Artifactory"
url "http://artifactory.terasology.org/artifactory/virtual-repo-live"
allowInsecureProtocol true // 😱
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Natives - Handles pulling in and extracting native libraries for LWJGL //
Expand Down
3 changes: 2 additions & 1 deletion engine-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ext {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Read the internal version out of the engine-tests module.txt
def moduleFile = file('src/main/resources/module.txt')
def moduleFile = file('src/main/resources/org/terasology/unittest/module.txt')

if (!moduleFile.exists()) {
println "Failed to find module.txt for engine-tests"
Expand Down Expand Up @@ -68,6 +68,7 @@ dependencies {
implementation("org.junit.jupiter:junit-jupiter-api")
implementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.mockito:mockito-inline:3.7.7")

implementation("org.mockito:mockito-junit-jupiter:3.7.7")

Expand Down
32 changes: 11 additions & 21 deletions engine-tests/src/main/java/org/terasology/engine/Environment.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
/*
* Copyright 2014 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License"){ }
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.engine;

import com.badlogic.gdx.physics.bullet.Bullet;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.assets.management.AssetManager;
import org.terasology.engine.context.Context;
import org.terasology.engine.context.internal.ContextImpl;
import org.terasology.engine.core.paths.PathManager;
import org.terasology.engine.recording.RecordAndReplayCurrentStatus;
import org.terasology.engine.registry.CoreRegistry;
import org.terasology.naming.Name;
import org.terasology.gestalt.assets.management.AssetManager;
import org.terasology.gestalt.naming.Name;

import java.io.IOException;
import java.util.Set;
Expand All @@ -50,8 +37,11 @@ public Environment(Name... moduleNames) {
try {
reset(Sets.newHashSet(moduleNames));
} catch (Exception e) {
logger.error("Error", e);
throw new RuntimeException(e);
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
}
}

Expand All @@ -76,7 +66,7 @@ protected void reset(Set<Name> moduleNames) throws Exception {
AssetManager assetManager = setupAssetManager();

setupBlockManager(assetManager);

setupExtraDataManager(context);

setupCollisionManager();
Expand Down Expand Up @@ -137,7 +127,7 @@ protected AssetManager setupEmptyAssetManager() {
protected void setupBlockManager(AssetManager assetManager) {
// empty
}

protected void setupExtraDataManager(Context context) {
// empty
}
Expand Down