How to configure "Shorten command line" method for whole project in IntelliJ

TestingIntellij IdeaSettings

Testing Problem Overview


When I run tests I get the error "Command line is too long". It works if I set the "Shorten command line" method in the Run/Debug configuration to "JAR manifest" for the specific method or class, but how do I set it for the whole project or is there an IDE global setting for it?

Testing Solutions


Solution 1 - Testing

Inside your .idea folder, change workspace.xml file

Add

<property name="dynamic.classpath" value="true" />

to

  <component name="PropertiesComponent">
.
.
.
  </component>

Example

 <component name="PropertiesComponent">
    <property name="project.structure.last.edited" value="Project" />
    <property name="project.structure.proportion" value="0.0" />
    <property name="project.structure.side.proportion" value="0.0" />
    <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
    <property name="dynamic.classpath" value="true" />
  </component>

If you don't see one, feel free to add it yourself

 <component name="PropertiesComponent">
    <property name="dynamic.classpath" value="true" />
  </component>

Solution 2 - Testing

Intellij 2018.2.5

Run => Edit Configurations => Choose Node on the left hand side => expand Environment => Shorten Command line options => choose Classpath file or JAR manifest

Screen shot of Run/Debug Configuration showing the command line options

Solution 3 - Testing

You can set up a default way to shorten the command line and use it as a template for further configurations by changing the default JUnit Run/Debug Configuration template. Then all new Run/Debug configuration you create in project will use the same option.

Here is the related blog post about configurable command line shortener option.

Solution 4 - Testing

Thanks to Rajesh Goel in Android Studio:

Run > Edit Configurations...

enter image description here

Select a test (better to select a parent test class) and set a Shorten command line: option to classpath file. Then OK (or Apply, OK).

enter image description here

Solution 5 - Testing

The latest 2020 build doesn't have the shorten command line option by default we need to add that option from the configuration.

Run > Edit Configurations > Select the corresponding run configuration and click on Modify options for adding the shorten command-line configuration to the UI. enter image description here

Select the shorten command line option enter image description here

Now choose jar manifest from the shorten command line option enter image description here

Solution 6 - Testing

If you use JDK version from 9+, you should select

Run > Edit Configurations... > Select JUnit template.

Then, select @argfile (Java 9+) as in the image below.

enter image description here

If you don't see the Shorten command line, then just clicking on Modify options menu as below, and select the Shorten command line

enter image description here

Please try it. Good luck friends.

Solution 7 - Testing

Add <property name="dynamic.classpath" value="true" /> to the .idea/workspace.xml file under the <component name="PropertiesComponent"> tag. That worked for me.

Solution 8 - Testing

Follow this steps and select "classpath.file" option from the dropdown list given in shorten command line category. enter image description here

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmomoView Question on Stackoverflow
Solution 1 - TestingMaulzeyView Answer on Stackoverflow
Solution 2 - TestingRajesh GoelView Answer on Stackoverflow
Solution 3 - TestingAndreyView Answer on Stackoverflow
Solution 4 - TestingCoolMindView Answer on Stackoverflow
Solution 5 - TestingJinu P CView Answer on Stackoverflow
Solution 6 - TestingturongView Answer on Stackoverflow
Solution 7 - TestingLahiru GunathilakeView Answer on Stackoverflow
Solution 8 - TestingPubudu Mahesh MeththanandaView Answer on Stackoverflow