简体   繁体   中英

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

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM