Locating source jars for Module Dependencies

I need programmatic access to the source jars or source directories, for all the dependencies for a particular module.

((ApplicationConfiguration) configuration).getConfigurationModule().getModule().

I was able to get some form of access to jar files with the above, but not to the source jars.

I can hack it by using information from:
     <project location>/.idea/libraries

But I would prefer access the info using the APIs. Is there a way to do this?

Comment actions Permalink

Of course, there is. ModuleRootManager.getInstance(module).orderEntries().recursively().sources().getRoots(). You can specify additional restrictions: for example, if you're only interested in dependent libraries and not the SDK or dependent modules, use orderEntries().librariesOnly(). For more details, see the OrderEnumerator class:


Comment actions Permalink

Thanks very much, works well.


Please sign in to leave a comment.