some questions regarding project layout
Hi,
I have a gradle project (java war web application) and activated "auto import enabled" so the project updates itself if i change the gradle file. In the gradle file I exclude the tomcat-servlet-api.jar and similar files so they don't end up packed in the war file. When debugging the application however, the jars land in the exploded war directory. I can exclude the jars via Project Structure/Artifacts dialog, but IDEA seems to forget this either when auto-importing from the gradle file or some other occasion. Is there a way to make IDEA respect the exclude directly from the gradle file or make IDEA not update the artifact setting and to share it in the VCS?
A similar problem appears when I try to group some of my modules into a module group. "Move module to group" works visually in the IDE but the settings don't seem to be reflected in the .idea/modules.xml file and get lost next time I start IDEA.
The third problem is, I have some directories at the same level as the modules (documentation and stuff). What is the recommended way to make them visible in the IDEA Project view? Do I need to create "empty" gradle projects for that?
Thanks!
--Kurt
Please sign in to leave a comment.
1. Did you try changing the scope of these dependencies to provided? How exactly do you exclude them via Gradle configuration? IntelliJ IDEA may not understand this specific logic, while using the scopes should work.
2. Groups will be discarded on reimport for Maven and Gradle based projects, it's by design.
3. Yes, configuring gradle projects for these directories should work.
Serge, thanks for the quick (world record time!) answer!
1) I was under the impression that the project specific scopes would be overridden too by the gradle auto import feature, but it turns out, it's not. I exclude the jars via:
war {rootSpec.exclude("servlet-api*.jar")
}
at the war level, but the dependency on servlet-api itself is defined in a subproject, so compileOnly (non-transitive) does not work. It's ugly but works, except for the exploded war.
2) Maybe the idea gradle plugin could be extended so that a module can define its group?
Thanks for your help!
1. See https://www.gesellix.net/post/providedcompile-and-compile-dependencies-with-gradle/, try providedCompile.
2. Vote for the related request: https://youtrack.jetbrains.com/issue/IDEA-153496.