pvoid / AndroidBlueprintPlugin

Plugin for IntelliJ IDEA which adds support for android blueprints and allows to create Android apps as a part of the system.
Mozilla Public License 2.0
7 stars 1 forks source link

[Feature request] Improve module structure building #26

Open Vlad8161 opened 2 years ago

Vlad8161 commented 2 years ago

The problem

Soong build system model is different with default idea project model. There is a couple of incompatibilities:

  1. Soong blueprint is a separate module with own sources, dependencies and artifacts. Set of blueprints share single content root directory but Intellij IDEA does not support different modules with the same content root.
  2. Also Intellij IDEA does not support selecting a single source file and only allows to create source folders. On the other hand soong allows to select files by wildcards.

This problems cause that Intellij IDEA project structure differs of soong's one. Current implementation does not allow to index sources and libraries correctly.

Possible solution

Take a look at demo https://github.com/Vlad8161/AndroidBlueprintPlugin/tree/blueprint-view. It's not a production ready implementation but can illustrate a core idea.

In this branch I've added a blueprint toolwindow that structures all AOSP blueprint in a tree view. Double click on a single blueprint creates a module structure of this blueprint that is built in a way that IDEA can understand.

Goals

  1. Provide a correct module structure to Intellij IDEA.
  2. Reduce resource consumption allowing not to index all AOSP tree.
  3. Provide a view to display blueprints structure.

How to test it

  1. Create an empty IDEA project.
  2. Open a blueprint toolwindow (on the right panel)
  3. Enter an absolute path to AOSP source root and click "Refresh" button
  4. Wait until it indexes all .bp files (now it's running in UI thread but should be moved to bg)
  5. Select a blueprint with type android_app or android_library (for example, SystemUI-core)
  6. Wait until plugin creates a directory and module structure.
  7. After it IDEA index all modules.

NOTE!! When modules are created Intellij IDEA starts to index sources but it does not show default 'Indexing' status. So you need to wait until dependencies are resolved. On my hardware it takes about 5-7 minutes to index SystemUI-core and it's deps.

Plugin creates a directory for selected module and all it's source dependencies. Then it creates a directory structure same as in AOSP but it does not collide between modules and includes to it all .jar dependencies. All files are created via a hard link to original files, so changes made in IDEA will affect original files. Also it calculates source roots based on "package" in .java and .kt files.

This demo does not support all features. It does not copy resources, aidl and hidl files (only its generated sources), R files. It does not configure kotlin and android facets. But all this features can be implemented in future.

dsh2 commented 1 year ago

@Vlad8161 There is no (public) repo AndroidBlueprintPlugin at https://github.com/Vlad8161.