Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building war with Gradle, Debugging with IntelliJ IDEA

I have JavaEE webapp project(named ProjectA) developed in IntelliJ IDEA.It has build.gradle file that applies war plugin :

apply plugin: 'war'

I want to debug(or run) gradle generated war file instead of debugging auto generated intellij artifact. It's very important for me that I can update classes changed during debugging without need to restart server.

enter image description here

How can I do it?

Note that :

1) When click refresh button in gradle plugin tab (refresh all Gradle peojects) Intellij updates all project configurations(for example module dependencies) and generate artifacts.I called it auto generated intellij artifact. enter image description here

For run it,I should only create new local Tomcat Server configuration and add artifact to deployment tab. enter image description here

enter image description here

2) In addition,there is some gradle tasks(clean,build,war and etc).I can execute build task or war task to generate war file.I called it gradle generated war file.

like image 954
vahidreza Avatar asked Dec 22 '14 20:12

vahidreza


1 Answers

Instead of deploying the IntelliJ build artifact, you can deploy an "External source" by clicking the "+" button in your final screenshot. You can then navigate to the artifact built by Gradle (in this case, the .war file in build/libs).

Second, you can instruct IntelliJ to run a Gradle task before running the configuration. Again, in your final screenshot, I would remove the second step labeled "Build 'Gradle ...' artifact" and add a step to run the Gradle war task.

like image 200
Mark Vieira Avatar answered Nov 09 '22 20:11

Mark Vieira