0

I am currently attempting to build a gradle grails 3 project, where it is using Spring-context-support as a transitive dependency under some Spring dependency at compile time as declared in my build file. My application does depend on the group and artifact/module as a whole(That is, Spring-context-support), however, I need to explicitly get rid of/exclude EhCache from within spring-context-support. I know syntactically how rid myself of the entire spring-context-support dependency, however I cannot seem to figure out how to remove JUST the caching...

A screen shot is attached to help illustrate what i mean: this line when uncommented will remove the entire spring-context-support dependency: enter image description here

Here you see the "cache" package, containing the Ehcache modules that I am trying to get rid of. How would I adjust the exclude declaration to remove this? enter image description here

William Tolliver
  • 305
  • 1
  • 2
  • 16

2 Answers2

1

Gradle (or Maven) will only allow you to exclude a dependency at the artifact level, that is not have the jar on the classpath. There is no first class support for filtering out a set of packages from a dependency.

For that, the easiest would be to repackage your application in a fat jar, filtering out the packages you deem unnecessary.

However the way your question is phrased makes me wonder if there is not a confusion. What you will find inside org.springframework.cache is not Ehcache code but instead the Spring caching abstraction. Ehcache library is either a module under group net.sf.ehcache or org.ehcache, and you could very well exclude these.

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43
  • Thanks a lot. This is the answer i was looking for. Im not trying to exclude the module entirely. im trying to get rid of the package. By the way you framed the answer, it wouldnt make sense for me to be able to outright exclude it. im not sure however what you mean about filtering out packages. I'll look into what a "Fat" jar is and try from there. Thanks – William Tolliver Oct 22 '18 at 02:29
-1

Excluding dependencies is described in the docs: https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:excluding_transitive_module_dependencies

Good luck!

  • I think you may have missed what I was asking. I have looked over the docs or transitive dependency management, I was however wondering if there was a way I had missed for dealing with excluding small stand alone modules within the dependencies themselves, or if you could only remove the entire dependency. Thanks – William Tolliver Oct 18 '18 at 14:43