I started using netbeans, and I'm setting up a gradle project.
I want to control what task is used when I use netbeans' "run" command.
It is defaulting to run "gradle run", but I want to pass in something other than "run".
I cannot find where to do that, is there a place edit "gradle run" ?
You can adjust all the built-in commands in the project properties: "Manage Built-In Tasks". For details see the wiki about project properties and built in tasks. If you prefer, you may add several "profiles" each with different build commands.
Related
Everytime I check out and open a project in Intellij I need to change the gradle plugin setting "Use Gradle from" from the default "'gradle-wrapper.properties' file" to "'wrapper' task in Gradle build script"
Is there a way in Intellij 2020 to make the shown option the default?
Reason I am asking: Generated gradle-wrapper files are not in our VCS, but the build.gradle is, and it has the wrapper task configured with the desired version. So when I check out a project, Intellij does not find gradle.properties (and neither can download gradle from web, as that is blocked). I then have to change the option "Use Gradle From" manually each time.
Another solution I tried is to automatically run a script when opening a module, which would run gradle wrapper with a fixed gradle version for the module, hence generating the missing wrapper files. But I find no possibility in Intellij to trigger that upon import..
It is not possible to change this setting for all projects. Please vote for this request: IDEA-215792.
I am running a spring boot application inside IntelliJ IDEA and noticed a difference if I run it via the run tab (run menu) and via manual command from the terminal tab.
If I run it through a maven run target (play button), I do not see any colors inside the 'run' tab. If I run it via 'mvn spring-boot:run from the 'terminal' tab I see the pretty color highlights. The maven run configuration also runs the same command, spring-boot:run.
Application started from the play button/run configuration (run tab):
Application started from the terminal tab via mvn spring-boot:run (terminal tab):
Inside build.gradle, add the following block to get colorized log output when running your Spring Boot app inside IntelliJ IDEA via gradle bootRun.
bootRun {
jvmArgs = ["-Dspring.output.ansi.enabled=ALWAYS"]
}
It's supported for the Spring Boot Run/Debug configuration type. It explicitly passes
-Dspring.output.ansi.enabled=always
JVM option enabling the color output.
As far as I know, ANSI colors support is not available when you run it in IntelliJ IDEA using Maven or Gradle configurations in the built-in console. Feature request is welcome.
In IDEA 2017.1 EAP I'm getting colours even if I'm just running the application with the standard run command
Edit:
Might be that Community edition doesn't support Spring Boot at all (https://www.jetbrains.com/idea/features/editions_comparison_matrix.html)
You can obtain the very same output also in the Community Edition with the previously mentioned option:
-Dspring.output.ansi.enabled=always
Simply go to "Run" -> "Edit Configurations..." and add the option in the "VM options:" field for your main class.
Is there a way I can set --info or --stacktrace via gradle.properties?
I currently have a gazillion build scripts that end up invoking gradle at some point, and I would like to standardize the error handling behavior across the board.
Not in gradle.properties but in build.gradle itself. Add the following piece of code at the very beginning of the build script:
import org.gradle.logging.ShowStacktrace
gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS
throw new RuntimeException('lol')
Or in Android Studio:
import org.gradle.api.logging.configuration.ShowStacktrace
gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS
It also might be put in init script.
As pointed out in the comments, from gradle v. 2.14 it will be:
gradle.startParameter.showStacktrace = org.gradle.api.logging.configuration.ShowStacktrace.ALWAYS
There is another approach where you do not have to edit the build.gradle file because you may not want it so verbose when you run your CI. In addition, you now have to remember to turn it off in CI. So, instead, you can limit to the IDE. If you are using eclipse, you can follow these steps to apply it only to gradle runs within your IDE.
Run -> "Run Configurations" -> Select "Gradle Project" -> Click "Project Settings" tab -> Click "Configure project settings..." link -> Select "Override workspace settings" -> paste "--stacktrace" in "Program Arguments" text field.
The above worked with Spring Tool Suite 4.2.1 which is based on Eclipse 4.11.0.x
Since Gradle 7.4 this is possible through gradle.properties.
org.gradle.logging.stacktrace=all
Docs: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
Added in https://github.com/gradle/gradle/pull/18713
I have a Spring Boot project with gradle build tool. The JDBC url, username and password are kept in a property file which is not part of application it's a external property file, the path of the property file is taken from system properties as follows.
export _JAVA_OPTIONS=-DdatabaseConfiguration=db.properties
It is working if I run the application from terminal using gradle bootRun, but when I try to run from Intellij IDEA 13 gradle tasks its not working, the property value is null.
I tried the VM options in Run/Debug Configuration as in the below screen shoot its not working either
How can the JAVA_OPTIONS can be set in Intellij IDEA 13 gradle tasks.
This is because every time you use the Gradle tool window to kick off tasks in IntelliJ, it creates/overwrites the launch configuration for that task.
Basically, I've had to run from the Gradle tool window just once. Then I go into the failed Launch Config (shown in question) and enter the system property in the VM options. From there on out, I need to use that Launch Config to execute the task instead of the Gradle tool window.
Update: Even better solution:
Preferences->Build, Execution, Deployment->Build Tools->Gradle->Gradle VM options
Add your system properties there (i.e. -Dappengine.sdk.root=/opt/google/google-cloud-sdk/platform/appengine-java-sdk)
Doing this will keep them from getting overwritten/lost in the Launch configs that the Gradle tool window generates.
Another thing to note is that using the Gradle tool window causes the commands to be run without access to Environment Variables. This can cause a lot of problems with builds that depend on these env vars.
I ran into this today with the appengine-gradle-plugin and had to put
-Dappengine.sdk.root=/opt/google/google-cloud-sdk/platform/appengine-java-sdk
in the VM options because it was not seeing the env vars. From the command line, it picks up the env vars and works fine. This worked for my appengineRun task.
But it does not work for appengineUpdate since that gives another error caused by lack of env vars: Toolkit not found: apple.awt.CToolkit
How to run following mvn commands via intelliJ IDEA? I can run these commands from terminal but how to do the same in the IDE for the project opened in it?
--mvn clean dbmaintain:updateDatabase
--mvn clean package
Go to "Edit Configuration" and create a new "Maven Run/Debug Configuration". There you can define the command line and the working directory.
An other way of doing the same is : open de maven projects view (on right edge of the window) expend your module, expand the "Life-cycle", select the phase you need to run. Then a simple rigth click shows a popup allowing you to "run" the phase or create a run configuration preconfigured with the working dir and the phase. (you can always edit it)