- labels: Intellij, IntelliJ --> IntelliJ
Description:
Host Alice has a Module which contains a test folder, sources folder, and a <modulename>.iml file. There are two classes in the src folder.
If the Host shares this Module in Intellij with Bob, Bob gets all the files (.java and .iml) but not the whole Module.
Problem 1: The folders containing the files are only shown as directories, independent of their host-side status (e.g. Module, src folder, test folder, etc.). As a result, Bob cannot create classes (as it's only possible in Java Module src folders, not in plain directories).
Problem 2: Empty folders are not transmitted.</modulename>
Problem-Analysis:
Comparing the two projects of Alice and Bob, the result is following:
In the .idea folder (which contains the project meta data), there are differences in
All other files are equivalent (except for own system configurations).
In the modules.xml file all Modules of the project are listed, and the transmitted Modul does not appear there. After copying the module.xml file from the Host to the client the corresponding module is shown correctly.
Another Problem (not solved with the Approach to Solution) is that nested Modules (Modules in Modules) are not transmitted correctly, because its hard to compute the path to the inner .iml file.
Approach to solution
Intellij provides a ModuleManager through the OpenAPI, which has a method "loadModule" to load a Module from an .iml file and add it to the project. This solves the problem.
To call this method, it is recommend to register a new class in the SarosLifeCycleListener and the Picocontainer so the method is called every time when Ressources are shared.
It is also appropiate to embed this method with
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
loadModule(filepath);
....
to secure thread safety.