IntelliJ IDEA: How to run gradle application plugin run task with --args

Viewed 1743

I have a java main program in my gradle project which I can run via command line using the gradle application plugin run task with --args param new since gradle 4.9 as follows:

gradle  run --args="-ahttp://foo.com/bar -dmydeviceid"

I would like to create a Run Configuration for the same in IntelliJ IDEA CE 2018.1.

  • I specify Task field in Run/Debug Configuration dilog as run.
  • I specify Arguments field as --args="-ahttp://foo.com/bar -dmydeviceid"

When I run this run config I get the error:

11:58:31 AM: Executing task 'run --args="-ahttp://foo.com/bar -dmydeviceid"'...

Unknown command-line option '--args'.

How can I make this work via run config?

1 Answers

The solution is to create a new Run Config as follows for the main program:

  1. Open Run/Debug Configurations dialog vie Edit Configuration choice in pulldown left of Run button
  2. Expand Defaults menu and select Application
  3. Click + to create an Application run config
  4. Enter your Main class
  5. Enter program arguments. For my example above it was: -ahttp://foo.com/bar -dmydeviceid
  6. Enter module in "Use classpath module". It is likely the one with suffix "_main"
  7. Click OK
  8. Now click run or debug button
Related