Update classes and resources in Gradle project

Answered

Hi there,

When I've got a Gradle-based web application running in Tomcat (in debug mode), IntelliJ gives me the option to 'Update classes and resources'. When I invoke this action, it looks like IntelliJ kicks off two Gradle tasks:

  1. classes, for all sub projects involved in the deployed application
    09:30:47: Executing tasks ':subproject1:classes :subproject2:classes :subproject3:classes ...
  2. The top-level war task
    09:30:47: Executing task 'war'...

Is there some way to change which tasks get invoked at this moment? I don't want to run the top-level war task, I only want to run that task for the sub project that is deployed (and any tasks it depends on, obviously). Running this tasks for the whole project is a waste of time here, as I don't need the war for other web applications in my project to get updated.

Thanks,

Guno

0
5 comments

That is correct. The IDE uses 'classes' task and 'war' tasks for 'Update classes and Resources' action for the Gradle module from which the artifact is produced. Unfortunately, the "incremental" update of the war artifact can not be done for non-exploded artifact, since the *.war file is overwritten. The update cycle should work faster once the IDEA-178450 request is implemented.

0

Thanks.
I've already got a workaround in place to explode the war, which is also mentioned in that issue:

tasks.register<Copy>("explodedWar") {
into("$buildDir/libs/exploded/${tasks.war.get().archiveFileName.get()}")
with(tasks.war.get())
}

I was actually hoping to be able to call that one when updating classes and resources. Or perhaps I could let the war task depend on this one. But since the top-level war task is now called, all my other web application sub projects are built as well at that point. That's what I'm aiming to resolve now, but as I understand correctly, there's on way to change this behavior.

Well, OK, guess I'll have to wait for IDEA-178450 then.

0

The IDE uses 'classes' task and 'war' tasks for 'Update classes and Resources' action for the Gradle module from which the artifact is produced.

As far as I can see, this is the case for 'classes', but not for 'war'. Otherwise I would have seen the output like this, right?

Executing tasks ':subproject1:war :subproject2:war :subproject3:war ...

But now it's like this:

 Executing task 'war'...

So apparently, the 'war' task  is not called for the Gradle module from which the artifact is produced, but for top-level. Or am I missing something here?

 

0

Indeed, war  task is called for the top-level (linked) Gradle project as a whole and we could improve this functionality. I've opened an issue for this: https://youtrack.jetbrains.com/issue/IDEA-258428
Please, watch/vote for it.

0

Please sign in to leave a comment.