'How to exclude a jar file that is compiled in the filetree of a subproject?

I have a really old gradle project "abc" that has a dependency on another subproject "xyz". The xyz project has a dependency on the filetree of its lib folder. One of the jar file "def.jar" in this lib folder is causing conflict in the parent project.

How do I exclude def.jar from the parent project gradle build?

Gradle version to be used : 2.9

abc build.gradle :

dependencies{
  .
  .
  compile project(xyz)
  .
  .
}

xyz build.gradle :

dependencies{
  .
  .
  compile fileTree(dir: "lib", include: '*.jar')
  .
  .
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source