Search code examples
javaintellij-idea

Shared run configuration in IntelliJ with modified classpath


In our project, we share IntelliJ run configurations (using a git repository) with #IC-232.10227.8 (2023.2.5). We have many run configs in the same IntelliJ module and one of them needs a different classpath than the module. Different means: less libraries than in the module dependencies.

Whenever we disable "Use classpath of module", apply and re-open the run configuration, the classpath is again set by the module. (The documentation keeps the explanation of this option rather short.)

This leads to a difficult situation:

  • we cannot modify the classpath via excludes because of IDEA-303236 -> developers would be bound to using the same local base path
  • we cannot modify the classpath via includes (even if macros work there) since the module classpath comes first - including is not the problem...

The only chance I see is to explicitly set the classpath via JVM command line argument (this overrides module classpath), which leads to a horrific non-maintainable single-liner

-classpath=/path/to/first/lib;/path/to/second/lib;...

Do we oversee something? It seems a flaw that IntelliJ cannot handle shared run configs with non-module classpaths.


Solution

  • Unfortunately, this is not possible unless the bug mentioned in the question is resolved. In IntelliJ, each run configuration is associated with a module (according to LJ replica's comment) and to create an additional module is not a solution in our case, since our modules are connected to git repositories.