Attaching a javadoc folder in a module-relative way via a plugin

I have a javadoc folder I'm trying to attach to an intellij plugin. ModuleRootManager is a class that supports manipulation of the module dependencies.

I managed to get it auto attaching using the ModuleRootManager and creating a path with addRoot("file://$MODULE_DIR$/javadoc-folder/",JavadocOrderRootType.getInstance()) on an instance of Library.ModifiableModel. This adds to the IML:
          <root url="file://$MODULE_DIR$/javadoc-folder/" />

It works well on absolute paths, however, when I use $MODULE_DIR$, it doesn't behave as I'd expect. If you look at the attached javadoc, it says that the path is to the literal text $MODULE_DIR$ until you reload intellij. $MODULE_DIR$ doesn't get refreshed / populated with the actual relative module path until intellij is reloaded.  Is there any way to force this process under the hood?

(I want to avoid absolute paths in case the user of my plugin commits their project file to source control)

Any thoughts / ideas / help would be greatly appreciated!

Comment actions Permalink

You don't need to force anything. Simply add the path as is, and IntelliJ IDEA will take care of storing it as a module-relative path automatically.

Comment actions Permalink

Ah! Then maybe I should file a bug!  Because it doesn't seem to handle it when it first adds it, I had to reload intellij to get it to trigger.

Comment actions Permalink

How exactly did you test?


Please sign in to leave a comment.