IntelliJ packages output of another project into the .jar inside a .war

Answered

In our company we have a Gradle project and unfortunately we can't get it to work with IntelliJ due to the following problem:

in short, we have three modules (in reality a lot more of course):
- warProject
- javaProjectA
- javaProjectB

with the following dependency structure

warProject\build.gradle:

implementation(project(javaProjectB))

javaProjectB\build.gradle:

api(project(javaProjectA)) 

The war that is produced by warProject is configured as an artifact in IntelliJ but when we build it, sometimes IntelliJ packages the content of javaProjectB into warProject\build\libs\exploded\warProject.war\WEB-INF\lib\javaProjectA.jar. 

Even more unfortunately this happens seemingly randomly! The only way to 'fix' it is to keep rebuilding the artifact until it is built correctly. 

The build logs show nothing, even with output level set to debug.

5 comments
Comment actions Permalink

Hi Jonas,

What is the configuration of your artifact in the Project Structure settings?

How do you build it?

What settings are used in File | Settings | Build, Execution, Deployment | Build Tools | Gradle?

0
Comment actions Permalink

Hi Arina,

thanks for replying! :) 

These are my gradle settings

and this is the artifact configuration 

 

it looks reasonable to me, especially given that it builds correctly sometimes. 

The compilation of the individual projects javaProjectA and javaProjectB (I just realized I dropped the prefix java sometimes, sorry about that) always works 100% correctly by the way. It's only when they are packaged into the war that their compiled contents get mixed up.

0
Comment actions Permalink

Thank you.

Does it make any difference if you tell the IDE to use Gradle to build and run your projects? File | Settings | Build, Execution, Deployment | Build Tools | Gradle > 'Build and Run using'

0
Comment actions Permalink

In that case, IntelliJ simply doesn't build the exploded artifact. (I.e. it only calls gradle to build the .war file, which is pointless)

 

I guess that is due to this known bug: Gradle: exploded WAR is not generated when 'Delegate IDE build/run actions to gradle' is enable : IDEA-176700 (jetbrains.com) 

has that been fixed in any version?

0
Comment actions Permalink

>In that case, IntelliJ simply doesn't build the exploded artifact. (I.e. it only calls gradle to build the .war file, which is pointless)

What IDE version do yo use? The mentioned request has been implemented since latest 2021.3 versions.

>sometimes IntelliJ packages the content of javaProjectB into warProject\build\libs\exploded\warProject.war\WEB-INF\lib\javaProjectA.jar.

This is really strange... Do you mean the projectB content is present in the output of warProject war and in javaProjectA jar? Considering that the javaProjectA even does not have a dependency on a javaProjectB? Is it possible to have a sample project, please? Thank you.

1

Please sign in to leave a comment.