Programmatically modifying a modules dependencies?

I have modules in a project that are dynamically loaded at runtime (OSGI bundles).  The executable module of the project is not dependent on these modules from a build-prespective.  I would like to programmatically add/remove those modules to the dependency tree of the executable module so they are built when you hit the Debug button.  Any way to do this?  Thanks.

0

Hello Erik,

I have modules in a project that are dynamically loaded at runtime
(OSGI bundles).  The executable module of the project is not dependent
on these modules from a build-prespective.  I would like to
programmatically add/remove those modules to the dependency tree of
the executable module so they are built when you hit the Debug button.
Any way to do this?  Thanks.


Sure. The starting point for this is ModuleRootManager.getInstance(module).getModifiableModel().
The API docs in the plugin development package should probably let you figure
out the rest.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Avatar
Permanently deleted user

Ive actually looked at that before, but the documentation is lacking, to say the least.  I will play around with it now that i know its the right

direction.  Thanks.

0
Avatar
Permanently deleted user

After playing with the API for a while, i notice that after modifying the ModifiableRootModel, the underlying model in the ModuleRootManager doesnt change.  Do i have to take the instance of this modified model and set it somewhere?  The compiler doesnt pick this new dependency list.

0

Hello Erik,

After playing with the API for a while, i notice that after modifying
the ModifiableRootModel, the underlying model in the ModuleRootManager
doesnt change.  Do i have to take the instance of this modified model
and set it somewhere?  The compiler doesnt pick this new dependency
list.


Make sure you call commit() on the model after you make the changes.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Avatar
Permanently deleted user

That makes perfect sense.  I didnt see that method.  Thanks a lot.

0
Avatar
Permanently deleted user

I am abel to add the dependencies to a module when the project opens.  These changes will be reflected in the modules .iml file.  What i am trying to do now is remove the dependencies when the project closes.  I really only want the dependencies to change during the development session.  I am removing the OrderEntrys from the model in ProjectClosing() from ProjectManager.  These changes are not being reflected in the .iml file for the module.  Is there a way for me to remove the dependencies at project closing or module unloading and have the changes be reflected in the .iml file?

0

Hello Erik,

The things you're trying to do don't really fit in well with IDEA's architecture.
.iml files can be saved to disk at any time, not in any particular point
of the project close operation. Also changing the dependencies is a heavyweight
operation (IDEA scans for files to be indexed and performs a number of other
updates), so such an approach will negatively affect IDEA performance.

I am abel to add the dependencies to a module when the project opens.
These changes will be reflected in the modules .iml file.  What i am
trying to do now is remove the dependencies when the project closes.
I really only want the dependencies to change during the development
session.  I am removing the OrderEntrys from the model in
ProjectClosing() from ProjectManager.  These changes are not being
reflected in the .iml file for the module.  Is there a way for me to
remove the dependencies at project closing or module unloading and
have the changes be reflected in the .iml file?


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"



0

请先登录再写评论。