I've used previously maven 3
and it was easy to run anything from IntelliJ IDEA 13
, be at main classes or tests - it worked through maven settings. But now I am trying to debug my java project in IDEA with Gradle 1.11
. The problem is that idea now creates /out/* directory and trying to run my classes from there instead of using gradle settings and build setups - I mean, with maven I could debug my java project by this:
maven install
and will run my java project from target/classes/
directoryBut with gradle project idea not uses gradle structure.
How can I debug my java project right from IDEA IDE with gradle?
P.S. I can run gradle test
under debug in IDEA and it works perfectly, but I need something like gradle debug
or gradle run
to set breakpoint in IDE, run my Main class and launch my java application through IDE. Hope it is clear what I want to do.
To do that, just pick the Gradle Remote Debug configuration and then click the Debug icon on the project to be debugged. For more info, you can read the Gradle documentation. Follow us for more productivity tools & ideas for Android, Kotlin & Gradle projects.
In the Gradle tool window, open the project's node, then the Tasks node and double-click the build task to run it. IntelliJ IDEA creates the build directory that contains our JAR file. You can run the created JAR file in the command line with java -jar command. Check the Run tool window for the results.
Open your project in IntelliJ IDEA. In the Project tool window, right-click the name of your project and select New | File. In the dialog that opens enter build. gradle and click OK.
Problem was solved by using application plugin
of gradle.
In build.gradle
we need to apply this plugin by adding line:
apply plugin: 'application'
And setup main class name:
mainClassName = "Main"
(Main is my main class).
After that in IDEA we need to create configuration to run gradle's run
-task and run it under debug.
But if you have a distribution
plugin applied to in your project they will conflict. You need to delete the line of applying distribution
plugin and any section of this plugin like distributions {...
Application plugin information
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