Background:
I've been using Eclipse for a while and am trying out Intellij now.
I checked out my project from Git (via Intellij) and recognized it as a gradle project. Its created the WAR(& the exploded WAR) all of which are fine.
Question:
When I was using Eclipse, I used the command:
gradlew -Penv=Development :my_webapp:assemble
This used to do a few things including creating a environment.properties
file that my dev specific env could use (for selecting database instances etc) based off of -Penv=Development
...I'd like the Intellij gradle build to do the same... What's a way to configure Intellij's gradle process to do these custom things or provide same features as provided by this specific command line tool (Note - the code for this is already written in build.gradle
file)...
I looked at some of Intellij's docs, but could not find an answer to this.
EDIT:
I've found the solution, for anyone interested - read on...
Seeking guidance from @Stanislav, I was able to add the property as follows:
Run/Debug Configuration
-->Your server's config(Jetty etc), there is a section called Before launch
, which should have Make/Build Gradle already included+
sign -->Run Gradle Task
--> Select your gradle project
(i.e. the web app) --> Select the task
(most likely loadEnvironmentConfiguration) --> set the script parameters
such as -Penv=Development
, hit OK
+
sign you hit in step 2)From the main menu, select Run | Edit Configurations to open the run/debug configuration for your project. icon. In the list that opens, select Run Gradle task. In the Select Gradle Task dialog, specify the project and the task that you want to execute before launching the project.
We can get to the settings from the Gradle Tool Window, or from the usual Settings/Preferences dialog (⌘, (macOS), or Ctrl+Alt+S (Windows/Linux)) and navigating to Build, Execution, Deployment | Build Tools | Gradle.
It seems, that you need to create your specific run or debug configuration. You can read about it in official IntelliJ Idea help. All you need, is to modify your configuration for the task you need, by providing the argument -Penv=Development
, since it is running with gradle.
You may also need to define Gradle instance, which will be used via settings, if the defaul wrapper wont work for you. You can find almost all you need in the the official help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With