Question

I maintain an IntelliJ plugin (Codename one) and we need to control the users classpath. I'm adding a classpath either via the plugin or manually by going to here:

enter image description here

And pressing the + sign where I pick Java:

enter image description here

Then choose classes:

enter image description here

This seems to work OK:

enter image description here

But the completion and other such functionality doesn't work and when I go back the entry is disabled and I get this error message:

enter image description here

This doesn't really tell me anything?

A workaround is to open the .iml file in a text editor, and add the following to the orderEntry list:

<orderEntry type="library" scope="PROVIDED" name="LibraryName" level="project" />

Unfortunately this isn't very practical and it only solves some of the problems I'm experiencing. Any direction or hint would be appreciated here.

Edit: Adding screenshot of preferences UI:

enter image description here

Second Edit: Screenshot of the module section

enter image description here

Was it helpful?

Solution 2

This doesn't really tell me anything?

IntelliJ is trying to warn you that you have created a library, but it is not referenced anywhere in the project. It is gently asking "Did you mean to add this library as a dependency?".

The entry is not disabled. It is greyed out to show that it is not referenced in any module as a dependency. Once you add the library to the dependencies list, the color will change.

It is a two-step process:

  1. Create a library
  2. Reference new library in a module

Code completion is not working because your module is not aware of the library classes.

Module dependencies

enter image description here

Non-referenced and referenced libraries

enter image description here

OTHER TIPS

The answer from kukido is good, for additional details though check out this: http://devnet.jetbrains.com/message/5509300

Essentially what I want is to still have my module but add a dependency programmatically which can be done by:

ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
model.addLibraryEntry(library);
model.commit();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top