How to add -P parameter to Gradle launch config?
Answered
From the command line I run my app with this -P parameter
./gradlew wp-web:backend:bootRun -PskipFrontendBuild=true
I can't figure out how to get it to work using a Gradle launch config in IntelliJ 2023.1. I've tried VM options and Program arguments and neither work. How can I get the run launch config to use a -P parameter when using Gradle to run? This -P parameter is used in build.gradle and not in the app.
Please sign in to leave a comment.
>I've tried VM options and Program arguments and neither work.
Since you want to pass a gradle parameter, you should use Gradle run configuration ype insted of the Spring Boot run configuration type to pass this parameter:
Alternatively, you can modify the build.gradle file directly in IntelliJ IDEA by adding the parameter to the "bootRun" task. For example:
This will set the "skipFrontendBuild" property to true if the -PskipFrontendBuild=true parameter is passed in from the command line.
Thanks for the help and it works, but wondering if there's a way to get it to run under Services tab? It currently runs under the Run tab. I would love to be able to start it under the Spring Boot/Services folder as I need all of these running.
Also, I didn't get the Create task right-click option that you mentioned in step 3. I did Modify Run Configuration... so maybe the same thing?
>wondering if there's a way to get it to run under Services tab?
Yes, you can add Gradle run configuration type to be displayed under the Services tab.
>Also, I didn't get the Create task right-click option that you mentioned in step 3. I did Modify Run Configuration... so maybe the same thing?
Yes, you are correct, sorry for the wrong option name.