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
feat: load modules from classpath (for dependencies) #41
Conversation
Something along these lines? except this doesn't actually work, as all the tests I've tried so far fail in a fiery death of NullPointerExceptions, but they do get past the dependency resolution stage. |
current status: lots of things passing in IntelliJ but failing under gradle. |
To provide a little more information when things fail and end up with NPEs later.
…the MTE module in the manifest.
I think I'm starting to see what's happening with the mess I'm in. The errors I'm running in to are when environment.getModuleProviding comes up empty: https://github.com/MovingBlocks/gestalt/blob/d8b35c056c5663d73497acdda7c01b9e32b0b439/gestalt-module/src/main/java/org/terasology/module/ModuleEnvironment.java#L298-L303 Asked about a type, it looks at that type's location, and then looks through all the environment's modules to see if any of them were registered with that location. When we only have jars for everything, this is fine. When we have sources and we're running under IntelliJ, it's also fine, because it puts Problem comes up when we have sources and we run under gradle. Gradle puts jars on the classpath, but when ModuleManager scans the So. Options:
🐘 I think it's possible do that thing with gradle, but there's no built-in option for it (at least as of gradle 6.8), so it'd be significant work. 🕶 preventing MTE from scanning |
Time for another Terasology Build Tune-Up Tuesday, with more fun facts about Gradle and IntelliJ! As we covered earlier, gradle puts jars on the runtime classpath, not classes directories. Except for the current subproject under test. The difference is probably because This becomes especially relevant when the build has things that are only triggered when building the jar, as is the case here: https://github.com/MovingBlocks/Terasology/blob/220c52dcb9d5a7b68f9d23bff2f80c85daf94649/buildSrc/src/main/kotlin/terasology-module.gradle.kts#L192-L197 That's one reason why your tests might not be finding module resources when invoked by gradle. As for IntelliJ IDEA: When IntelliJ IDEA imports a gradle project, it makes an IdeaModule (not to be confused with a Terasology module!) for the project, and sub-modules for the main and test source sets.
The complication for us comes in when we consider resources. IntelliJ IDEA won't run a gradle The assets of a Terasology module are stored in We can add If we were using IntelliJ alone, we would solve this by setting the relative output path for In gradle, we can set Long story short: Avoid build configuration headaches by keeping your resources in a resources directory. |
In recent comments on #4543, I suggest giving up the current attempt to move ModuleLoadingStuff over here. If we do that, does anything in this PR remain relevant? It looks like there are some debugging nice-to-haves we can extract to a separate PR, and might as well start a fresh one for whatever toggle mechanism #4543 ends up offering us. "Should we care if classpath modules are also on the module path?" is a question worth remembering, Lines 51 to 53 in 0884c43
but we can probably get away with not answering it until after gestalt-v7. |
extracted some things to #42. |
If engine's ModuleManager doesn't load all modules on the classpath by default, how are MTE tests going to get their dependencies?
Companion to MovingBlocks/Terasology#4543