Hot Swap changing all classes

Answered

I am running a Gradle project and in my run configuration for tomcat I am calling a war task and running the exploded war artifact. The build and run work fine but when I attempt to update resources and classes it swaps all 4000+ classes instead of just the ones that have been edited. However on subsequent attempts on the same debug session it only swaps the edited files and behaves as expected.

0
17 comments

This is my current run configuration:

0

I thought I was using the exploded war artifact. The Gradle step is just there to produce the war. When I am in the build configuration I am selecting 'Gradle : projectname : project-dev.war (exploded), is that the wrong way to set it up? The deployment config looks like this:

0

Use IntelliJ IDEA artifact, not Gradle. We have no control on what Gradle changes when building the artifact.

0

Can you explain what you mean by IntelliJ IDEA artifact?

0

See https://www.jetbrains.com/help/idea/artifacts.html. Gradle build step is probably what causes the problem.

0

Ah I follow you now, The problem is that when I select the artifact I need it does not build the artifact and I get a error saying it cannot be found:

Connected to server
[2017-10-27 02:48:38,261] Artifact Gradle : verafin : verafin-dev.war (exploded): Artifact is being deployed, please wait...
[2017-10-27 02:48:38,268] Artifact Gradle : verafin : verafin-dev.war (exploded): Error during artifact deployment. See server log for details.
[2017-10-27 02:48:38,268] Artifact Gradle : verafin : verafin-dev.war (exploded): com.intellij.javaee.oss.admin.jmx.JmxAdminException: com.intellij.execution.ExecutionException: /Users/dan.greene/Repos/TestNewGradleSetup/verafinci/dist/exploded/verafin-dev.war not found for the web module.

0

You need to configure the artifact in IntelliJ IDEA and configure it to be built before running by IntelliJ IDEA, in the deployment tab of the run configuration specify IntelliJ IDEA artifact configuration, not external source built by Gradle.

0

I have it configured to use the artifact but it is not producing the exploded artifact. When run Build>Build Artifact it is just calling the gradle 'war' command and not exploding the war. I have a number of different artifacts available and they all do the same thing produce a generic war and fail to explode it.

0

This is the output

 

3:02:04 PM: Executing external task 'war'...
:local-config:compileJava NO-SOURCE
:local-config:processResources UP-TO-DATE
.

.

.

:verafinci:classes UP-TO-DATE
:verafinci:war

BUILD SUCCESSFUL in 10s
18 actionable tasks: 1 executed, 17 up-to-date
3:02:14 PM: External task execution finished 'war'.

0

Indeed I was, that seems to be the culprit! IntelliJ seems to be deploying as expected now. The issues I am hitting now are from our own code. Thanks for the help!

0
Avatar
Permanently deleted user

Now its 2019 and delegate-to-gradle is both the default and the recommended setting,  yet there is no exploded war directory built in this configuration making Tomcat deployments (or any other applicatoin server) deployements  not work.

 

What is today's recommendation ? 

 

0

Don't use Gradle delegation for hot deployment.

0
Avatar
Permanently deleted user

re Serge, "Don't use Gradle delegation for hot deployment."

Unfortunately for all of my apps that are web servers IntelliJ no longer works properly unless I delegate builds to Gradle.

This started happening about a year a go and slowly got worse over time to where now its unusable if I don't delegate to gradle -- too many incorrect errors in the editor. 

0

We can investigate why it doesn't work properly if you report an issue at https://youtrack.jetbrains.com/issues/IDEA with the small sample to reproduce.

0
Avatar
Permanently deleted user

I have mine working with Gradle delegation.  Key things:

  • Make sure exploded war artifact points to where your gradle builds your exploded war.
  • Make sure to have Gradle task for exploding war called before deployment
  • Under the hood, when you reload classes, Intellij will call classes target on your gradle project

I am using 2019.3

0

Please sign in to leave a comment.