Search code examples
intellij-ideacodenameoneintellij-plugin

Adding a directory path under IntelliJ 12 claims Library 'LibraryName' is not used and has no effect


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


Solution

  • 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