Multi-module mode without maven? [message #1863986] |
Sat, 09 March 2024 15:49 |
|
The problem:
I created a new project with an initial module-info file, but I'm experiencing difficulties in getting the folder structure and package namespacing to work. I want to have multiple modules, so I moved the module-info into the right folder, and at some point the file started to give an error on the existence of a particular package in the exports statement, but upon re-completing the identifier the errors disappeared again. But they come back later when I haven't made any changes (no consistency there).
After some more tweaking I finally got it to run from one single main class inside the module, when I press Run from within its class file. I have two classes with a main method now, but it refuses to run the second class, which is within the same package. It complains that it can't find/load it or something. I couldn't understand what was going on, so after a negative emotional breakthrough I decided to delete the module-info and fall back to the default module mode thingy with just packages in the src root and a basic module-info (to configure the used gson lib). I don't know what to do. If I can't have multiple modules, I'll just won't have any at all.
File structure:
This is essentially what I had before I deleted module-info. I wanted the package names to continue with the same name as their parent module, since I thought that would make organizational sense to me.
src
└── mycompany
├── core (module "mycompany.core")
│ ├── main (package "mycompany.core.main")
│ │ └── Root.java (class with public static void main)
│ │ └── JsonExample.java (class with public static void main)
│ └── module-info
└── data (supposed to become module "mycompany.data")
└── Student.json (static unrelated json file)
lib
└── gson (library)
I didn't create the module descriptor yet for the data module, nor added any packages to it, it is just a plain folder for now with the json file directly in it without any code referring to it. And as from the above story, I tried to run from JsonExample, it worked fine and gave an output. Then I tried to run from Root, and although it is in the same folder as the other class and also has a main method, this class caused a fatal error in the console, no exception, no stacktrace.
Environment status:
New to Java 9 modules, trying to start a Java 17 project with multiple modules. Never used Maven before.
Using Eclipse Scout (with PHP and Web plugins for unrelated projects) version 2023-12, all plugins are up to date without errors.
About Maven:
This is going to be my first Java 17 project. I did have prior experience with Java 7 & 8, but I've studied everything that's new up to 17. I'm enthusiastic about the introduction of modules, and have ideas how I want to organize my project using multiple of them. But after two days of research on the subject of using multiple modules in Eclipse, I've concluded that this is not actually supported, but can only be accomplished using Maven. Correct me if I'm wrong. However, I do not want to use Maven, because it seems to be a massively complex system intended for something I haven't been exposed to yet, to even worry about. So when I later experience the difficulties that Maven is designed to overcome, I'll look into adopting it by then and not sooner. This is how my own learning curve works.
TL;DR: this is my question:
Is there a way to get this concept of multiple modules to work within the same project, without Maven?
Broken down into multiple parts:
- Do I need to do something special with the module-info files?
- Why can't I find the option anywhere to create a new Java module, within the File>New menu?
- And in relation to that, is that essentially what they mean with a "Maven module"?
- Do you need me to try to reproduce the problem again (and post more about my code) so you can help fixing the situation in case multiple modules per project is definitely possible?
- Could you please explain why Eclipse (still) forces a single module per project in case multiple is not possible?
- Is there an easy alternative to all or a part of this?
I'm incredibly enthusiastic about Java having introduced such a great concept as modules, but then tremendously let down that Eclipse restricts me to only have a single one in my project. If that is indeed the case. Please help.
* Edit: reinstalled newer IDE version, removed the previously relevant corruption info from post
[Updated on: Tue, 12 March 2024 15:41] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02888 seconds