Two Independent Projects - using one as a dependency

I am somewhat new to Gradle. I am converting several legacy projects to use Gradle. In my scenario I have two projects that are at the same directory level. Let’s say ProjectA and ProjectB, where ProjectB is a dependency of ProjectA (and in my case ProjectB is a dependency to about 100+ other projects). The legacy projects have dependencies (jars) in lib folders. As a first phase in converting these legacy projects to use Gradle I will keep the dependencies in the lib folders. (Phase 2 will use Maven Central.) So, here is what I have:

ProjectA
  |--build.gradle
  |--settings.gradle
ProjectB
  |--build.gradle

ProjectA/settings.gradle

    ...
    includeFlat 'ProjectB'
    ...

ProjectA/build.gradle

apply plugin: 'java'
apply plugin: 'war'
...
dependencies {
    providedCompile fileTree("$webAppDirName/WEB-INF/lib")
    compile project(':ProjectB')  
}

ProjectB/lib has five jar files. Only three of these jar files are needed for it to build. The other two jar files are used by another project, let’s say ProjectC.

When I assemble ProjectA, the resulting war file contains all five jar files from ProjectB/lib and the jar of ProjectB. My question is, shouldn’t the war file contain only the three jar files since the other two are not used by either ProjectA or ProjectB and how do I make this work in Gradle?

Any help with this would be greatly appreciated.