Adding directory to classpath in Run/Debug configurations


I am relatively new to IntelliJ migrating from Eclipse and I have a question regarding the setup of our project and how I can run applications and unit tests.

It is a rather legacy application and the structure is something like this

  - dist
      -- All dev configuration
      -- All unit test configurations
  - src

When  I want to run unit tests I need the configuration which is in UNIT-TESTS and  when I run an application I need the configuration in DEV
In  eclipse we just added dist/DEV/config or for tests the  dist/UNIT-TESTS to the classpath via a variable in the Run/Debug configuration but in IntelliJ the only I can get it to work is to add a library to  Module/Dependencies/{dev-config} or a unit  test  library but this needs to be changed if I want to run a test of an application.

So to summarise when I run a unit test I want it to pick up the configuration in one location and when I run an application another without having to change the dependencies of the module.
I have tried to just set my own -classpath which works to a point but doesn't feel right

I  am sure I am missing something here so any help would be welcome.

Comment actions Permalink

It's not possible to specify classpath manually per Run/Debug configuration, this enhancement request is tracked by

You should separate your sources and tests into different modules so that each module has its own classpath that can be selected in the Run/Debug configuration, another option is to create a new dummy module with no sources, but just libraries added to the dependencies and choose this module in the Run/Debug configuration classpath setting.

Comment actions Permalink

I am a relatively new user of Intellij and I have gotten to like it a great deal. I have been following threads on classpath management for a while, and frankly I don't understand some of what appears to be coming from people who have input into the product.
Please correct me if I am wrong, but it appears from several posts that the only way to reliably manage a classpath that needs arbitrary elements outside the scope of any project module is to use Xbootclasspath/a: or the like. It has been suggested to create dummy projects to add jars just for the sake of handling this problem. Am I the only one that feels that the existence of this whole issue and a kluge like the one just cited violates all of Maven dependency management?

Please let us control our run/test classpaths in any way we see fit - the eclipse model works just fine.



Please sign in to leave a comment.