first of all a little background: We develop a SDK to push Java code to many platforms (Android, iOS, JVM, Web)
from both a single-code base as well as allowing users to write dedicated applications.
I recently started developing a plugin for IntelliJ IDEA which is open-source at https://github.com/defrac/defrac-plugin-intellij/
Setting up the SdkType was simple, and I think that a Run/Debug configuration is also easily done. However I am not
quite sure how to represent our project structure in IDEA.
Our project structure, or the gist of it:
|_ java (generic source visible to all platforms
|_ java.ios (visible only when building for ios)
|_ java.web (visible only when building for web)
|_ java (generic macro source, visible only to compiler)
|_ java.ios (ios macros, visible only to compiler when building for ios)
|_ java (generic java bytecode from src/java)
|_ java.ios (bytecode from src/java.ios)
|_ ios (ipa etc)
|_ web (generated js etc)
|_ resource.png (visible to all platforms)
|_ resource.ios.png (overwrites resource.png for ios)
|_ asset.web.png (only visible to web, no generic file available
|_ ... (contents available only to ios)
|_ generic.jar (visible to all platforms)
|_ server.jvm.jar (visible only when targeting jvm)
Now the way we create a project at the moment is by entering "defrac create" to create a plain
project and then "defrac ide-intellij" which generates .idea, modules.xml etc.
Right now, we create a distinct module for each target platform. We do this obviously because there is no plug-in.
- The web module does not see code from iOS module
- The web module can be linked to the "Generic" module
- Macro source code, which is executed at compile time, is not visible to runtime modules
- The project consists of (Platforms + Generic) x (Macro + Runtime) modules: For 4 Platforms, that makes 10 modules
- Modules are shown with weird names which leads to a lot of confusion
- Project does not feel like a single instance
Attached is a screenshot of the project structure at the moment.
As you can see, the names of the source folders are shown in the form "directory [module] (sources root)" and this is confusing.
This brings me to the main question.
We would like to create a single module using the plug-in. The IDE should handle the dependencies and visibilities. Ideally
we configure source folders with a scope, like "ANDROID". Then the source root will only see classes from libraries and other
sources scoped "ANDROID" or "GENERIC".
How do I add an attribute, scope, to a Java source root?
I saw that there is JavaSourceRootType (side question: is jps documented somewhere?) and it allows me to specify the
package prefix as well as the generated attribute. Can I extend JavaSourceRootType or do I have to create a new
SourceRootType? If so, how would I let IntelliJ know that it is actual Java source since I tried it without much success.
The SDK contains currently also a set of libraries that are not "scoped". In general, this question extends over the whole
plug-in since I would need to add this attribute also to the class path entries of the SDK.