How can I make "gradle --stacktrace" the default? - gradle

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

Related

Run Corda project on IntelliJ

I'm using a MacBook Air OS X 10.9 (Mavericks) and IntelliJ IDEA, but the IDE won't let me execute the test "ProjectImportedOKTest" which is in src/test/java/java_bootcamp/. I followed the exact same steps of this video:
https://www.youtube.com/watch?v=ZgKxjwImKAs&index=3&list=PLi1PppB3-YrVq5Qy_RM9Qidq0eh-nL11N
But for some reason my green arrow to run the test is always disabled. It could be something with the configuration option in the top left of IntelliJ, which I left blank or even something with gradle.
Thanks a lot!!
You can invalidate the caches of the intelliJ by using the option
file -> invalidate caches/Restart.
It helped for me.
There are several things you could try.
Ensure that your source java or kotlin folder is marked as "Sources Root". Do this by right clicking the folder and selecting "Mark Directory as"
Go to view -> Tool Windows -> Gradle and hit the refresh icon
Try opening the project a different way, such as importing the project or just opening the project
Rebuild the project and ensure there are no errors
Go to File -> Project Structure and ensure Java 1.8 is set as the Project SDK
Got to File -> Settings 0> Build, Execution, Deployment and select Gradle. Ensure Gradle JVM has Java 1.8 and that "Use default gradle wrapper" is selected.
Again under Settings and Build, Execution, Deployment, go to Compiler -> Kotlin Compiler and check that Target JVM version is set to 1.8
I ran into the same problem running on Windows and ran into this question trying to find the solution. It turns out Gradle wasn't installed on my machine and that was causing the problems.
According to the Corda Docs - "Gradle - we use 4.10 and the gradlew script in the project / samples directories will download it for you."
However, I installed from the Gradle website here - https://gradle.org/install/#with-a-package-manager -and configured it in the PATH variable. After doing so, my green arrow was enabled and I was able to run the test successfully.

IntelliJ & Maven - mvn command not found

I'm trying to build a drop wizard project created with IntelliJ.
when I run
mvn package
I get
bash: mvn: command not found
I'm on a Mac and I'm following this tutorial: http://www.dropwizard.io/0.9.2/docs/getting-started.html
According to IntelliJ documentation (https://www.jetbrains.com/help/idea/2016.1/maven.html?origin=old_help)
Maven integration is shipped with IntelliJ IDEA, and you do not need to perform any additional actions to install it. You can start using it straight away for importing Maven projects, working with them and for running Maven goals.
So I don't know what I'm suppose to do in order to use the command line
Any idea?
Thanks
In IntelliJ, on the right hand side, click "Maven", and expand "Lifecycle"
Select "Package" and click "Run" (green arrow).
mvn is the command line tool for Maven.
See https://maven.apache.org/install.html for details on how to install it.
Or as you are using a Mac if you use brew try using it to install the maven formula.
If you have maven properly installed and you want to configure intelliJ terminal with a custom Terminal or if you want fix "command not found",
follow these steps:
Click > File
Click > Settings
Click > Tools
Click > Terminal
Edit "Shell path" # "Application Settings", if you use git bash change current path with:
C:\Users\Work\AppData\Local\Programs\Git\bin\sh.exe --login
// The path you may have differs based on your OS, in example: "installationPath\Terminal Folder\bin\sh.exe --login"
Click > Apply
Click > Ok
I used git bash but technically it should work with every terminal. Do not forget to add --login after the *.exe
If it still doesn't work maybe you need to check:
Click > Environment variables
Click > System Properties
Click > Environment Variables
Click > System Variables
Select > Path from the list
Click > Edit
Click > New
Insert the path of your maven bin folder, in example:
"installationPath\apache-maven-3.8.6\bin"
Also insert the path of your jdk, in example:
"installationPath\Java\jdk-18.0.1.1"

cant' install sublimemaven plugin successfully

I follow this https://coderwall.com/p/etesrq to install the sublimemaven plugin for my sublime2.
All steps seems ok, but I can't get the 'Maven' menu item in 'Tools->Build System'.
I have added the
"m2_home": "F:/jill/job/software/apache-maven-3.0.4",
add
"maven_menu_commands":
by following https://github.com/nlloyd/SublimeMaven.
and restart sublime2 several times.
but still can't get it.
Could some body help?
Thanks
I find that I don't have "maven" in "tools" -> "build system" either, but using cmd + shift + p , then type in "maven", I can see several commands, one of them is "maven: Run...", I use this command when I need to specify one. Commonly, other default maven commands could satisfy your requirement.
Nick Lloyd's SublimeMaven plug-in installed nicely for me on Sublime Text 3 but showed build commands only in the Command Palette (CTRL+SHIFT+P).
Only after I added Andres Koetter's configuration file to the Packages/User directory of my portable SUBLIME_TEXT_3/Data/ dir (or ~/.config/sublime-text-3/ for some) I found a Maven build option in the Tools > Build menu. This new option enables Sublime Text 3's build system run commands for Maven builds, that is:
Build (CTRL+B) : run default build configuration
Build with ... (CTRL+SHIFT+B) : select mvn goals, profiles, command-line options, etc.
Just adding a working directory tip that I found on this URL: https://gist.github.com/4ndrej/5162986
Once I finished instructions provided by user2951392, I got working Maven menu on sublime text 3. Then I tried to build some projects, but for each one of them I got an error like this: "...there is no pom.xml file on directory E:\sublime...".
So, just change the following content on Maven.sublime-build file:
old: "$file_path"
new: "${project_path:${folder}}"
With this final change I got my sublime text 3 and Maven 3+ working fine.
Cheers!

Netbeans Gradle config

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.

applying mvn commands via intelliJ IDEA

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)

Resources