-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Example Brokk.ai-based fix of a bad logging dir on startup #5308
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
Open
Cervator
wants to merge
4
commits into
develop
Choose a base branch
from
brokk/logs-fix
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+78
−9
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
597cd4f
Brokk base files
Cervator 4163ee5
refactor: use stdout for homeDir in Terasology before logging init
Cervator 888c73a
refactor: simplify logging setup and reorder in Terasology
Cervator 8e6a3e6
fix: initialize logging in Terasology before loading PathManager
Cervator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Terasology Coding Style Guide | ||
|
|
||
| This guide captures the specific coding patterns and Gradle conventions found in the Terasology codebase, focusing on modern Gradle Kotlin DSL (KTS) usage and engine-specific architectures. | ||
|
|
||
| ## 1. Build System & Gradle (KTS) | ||
|
|
||
| The project uses Gradle Kotlin DSL with a centralized `build-logic` composite build. | ||
|
|
||
| ### Dependency Management | ||
| - **Version Catalogs**: Use the `libs` catalog in `settings.gradle.kts` for common dependencies. | ||
| - **Constraints**: Use `constraints { ... }` blocks to force specific transitive dependency versions (e.g., forcing a newer `bytebuddy` for Java 17 compatibility). | ||
| - **Dependency Substitution**: Use `resolutionStrategy.dependencySubstitution` to swap remote module dependencies with local project sources when available. | ||
| - **Platform BOMs**: Use `platform()` for grouping related dependencies (e.g., LWJGL). | ||
|
|
||
| ### Task Configuration | ||
| - **Lazy Registration**: Favor `tasks.register<Type>("name")` over `tasks.create`. | ||
| - **Property Delegation**: Use `val propertyName by extra("value")` for sharing variables across subprojects. | ||
| - **Inputs/Outputs**: Always define `outputs.dir` or `outputs.file` for custom extraction/copy tasks to support Gradle's up-to-date checks and automatic `clean` task generation. | ||
| - **Duplication Strategy**: Explicitly set `duplicatesStrategy = DuplicatesStrategy.EXCLUDE` when merging resources or classes from multiple source sets. | ||
|
|
||
| ### Java Toolchains & Compatibility | ||
| - **JVM Toolchain**: Strictly target Java 17 using `jvmToolchain(17)`. | ||
| - **Validation**: Include runtime checks in build scripts to warn users if the `JavaVersion.current()` deviates from the expected version. | ||
|
|
||
| ## 2. Java & Engine Architecture | ||
|
|
||
| ### Dependency Injection & Context | ||
| - **The `@In` Annotation**: Use the `@In` annotation for automatic service injection within NUI screens and engine components. | ||
| - **Context Registry**: Use `context.get(Class<T>)` to retrieve engine services and `CoreRegistry.put()` for global accessibility when necessary. | ||
|
|
||
| ### Resource & Asset Handling | ||
| - **ResourceUrn**: Always use `ResourceUrn` for identifying assets (e.g., `engine:universeSetupScreen`). | ||
| - **Asset Templates**: Store static configuration templates in the `/templates` directory and use custom tasks like `CopyButNeverOverwrite` to initialize them into the project root. | ||
|
|
||
| ### UI Development (NUI) | ||
| - **Binding Pattern**: Use `Binding<T>` and `ReadOnlyBinding<T>` to link UI widgets (like `UIText` or `UIDropdown`) to underlying configuration data. | ||
| - **Widget Subscription**: Use `WidgetUtil.trySubscribe(this, "widgetId", handler)` for cleaner event handling. | ||
| - **Wait Popups**: Long-running operations (like world preview generation) must be wrapped in a `WaitPopup` using `Callable` operations to keep the UI responsive. | ||
|
|
||
| ## 3. Automation & CI (Jenkins) | ||
|
|
||
| - **Declarative Pipelines**: Use Jenkins Declarative Pipeline syntax with `post { always { ... } }` for test result aggregation. | ||
| - **Static Analysis Integration**: Build stages should explicitly trigger `recordIssues` for Checkstyle, PMD, and SpotBugs. | ||
| - **Flaky Test Management**: Segregate tests using JUnit 5 tags: | ||
| - `unitTest`: Fast, excludes `MteTest`/`TteTest`. | ||
| - `integrationTest`: Slow, includes `MteTest`/`TteTest`, excludes `flaky`. | ||
| - `integrationTestFlaky`: Only runs tests tagged with both integration tags and `flaky`. | ||
|
|
||
| ## 4. Metadata & Versioning | ||
|
|
||
| - **Module Metadata**: Engine and module versions should be mastered in `module.txt` (JSON format) and read into the build system via `JsonSlurper`. | ||
| - **Version Info**: The build must generate a `versionInfo.properties` file containing Git hashes, build numbers, and timestamps to be bundled within the JAR for runtime diagnostics. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log path wrong when homeDir is null
High Severity
When
homeDiris null (the default for most users who don't pass--homedir), the fallbackPaths.get(".")directs logs to the current working directory. Previously,setupLoggingobtained the log path fromPathManager.getInstance().getLogPath()afterhandleLaunchArguments()had calleduseDefaultHomePath(), which resolves to a platform-specific directory (e.g.,~/.local/share/terasology/logson Linux). The new code cannot replicate that logic without loadingPathManager, so it silently writes logs to the wrong location for the common no---homedircase.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good bot! I had wondered about this. Would you recommend a fix or is this a tricky case?