processResources and IntelliJ web artifacts


(Tobias Gesellchen) #1

Hi group,

when simulating the maven war overlay with something like below I cannot use the usual IntelliJ way of deploying a webapp to a JEE container like Tomcat: ‘’’ processResources {

from {

configurations.gwtEntrypoints.collect { gwtEntrypoint ->

zipTree(gwtEntrypoint).findAll { file ->

!file.parent.endsWith(‘META-INF’)

}

}

} } ‘’’

I didn’t find a way of telling IntelliJ to also copy the zip file contents to its temporary webapp folder.

Do you have an idea how to solve this, preferably by using the idea plugin and not by manually changing the IntelliJ project config?

Thanks!


(strug) #2

Not sure if it works, how about adding the resources from “anotherGwtEntrypoint” to your webapp/war?

war {

from project(":anotherGwtEntrypoint").fileTree(“src/main/webapp”)

}

or if “:anotherGwtEntrypoint” is a war

war {

with project(’:anotherGwtEntrypoint’).war

}

This is based on this thread


(Tobias Gesellchen) #3

Both ‘war’ and ‘processResources’ extend AbstractCopyTask so the outcome is the same for me. Using the ‘war { with { … } }’ syntax didn’t work, too. IntelliJ just doesn’t seem to use or execute those parts of the build script.

The problem seems to be a missing merge of Gradle script to IntelliJ project settings, but since there are quite a lot of different possible solutions I’d like to ask here first for a recommended way before going to Jetbrains with a feature request :wink:


(René Groeschke) #4

Hello Tobias, can you elaborate a bit more what you mean by “simulating the maven war”? In general running eclipse or idea task does not trigger the processResource task. but you can change them to depend on processResources


(Tobias Gesellchen) #5

Hi Rene,

I should have emphasised the “war overlay” part, but I’m happy to elaborate a bit:

We are currently migrating from a Maven build to a Gradle build. Maven allows us to modify a .war artifact by using so called overlays. When writing “simulate” I wanted to express that we’re trying to implement the same behaviour in Gradle by adding files during the ‘processResources’ task.

So, the first question is: would that be the Gradle way of replacing the Maven war plugin?

If so, we would like to declare the custom steps during the processResources task only once and we wouldn’t like to manually configure the deployable artifacts in the IntelliJ Web Facet. We would prefer to let IntelliJ recognize our custom steps or at least perform the tasks automatically when deploying the webapp via IntelliJ.

I guess we have to apply the idea plugin, but I don’t know how to configure the plugin to make IntelliJ apply the processResources just before deploying the webapp. Would adding a ‘idea.dependsOn(processResources)’ be enough?


(René Groeschke) #6

Now I get what you mean with war overlay. I’m not sure if processResources is the right task here to modify. My naive approach would be to change the war task to include the resources from another war like

war{
    from(zipTree("mydependent.war"))
}

My guess is, that trigger any gradle tasks when “deploying the webapp” via intellij. Does it support maven overlay out of the box? Or did you custom modifications for that too? A workaround might be to change the naive implementation is sketched above and create a “generateOverlayResources” that your idea task depends on. This task just copies all resources from the dependend war into a seperate resource folder.


(Tobias Gesellchen) #7

It seems to me that IntelliJ has support for the maven overlay feature or at least IntelliJ seems to use the result from the processResources task.

So I guess there’s no special or recommended way of making IntelliJ recognize special resource handling of Gradle scripts. Before I try working with the IdeaModule or Idea plugin or asking the Jetbrains team, would you have any hints or suggestions where to start? I read about different options when using the IdeaModule, but I wouldn’t see any way of modifying the artifact sources from IntelliJ’s point of view.

Thanks for your help!