Building war with Gradle, Debugging with IntelliJ

2019-03-16 09:06发布

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.

1条回答
闹够了就滚
2楼-- · 2019-03-16 09:50

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.

查看更多
登录 后发表回答