How to put jars from all subprojects into one directory?

I have a multi project project build as follows and when I do gradle clean build it creates jars under build/libs/ of each sub directory like below

root
   /projectA
       /build/libs/projectA.jar
   /projectB
       /build/libs/projectB.jar

Now I want to have all these subprojects jars (project A & B) in one place (say root/build/libs) so it would like this

root
   /build
       /libs
           /projectA.jar
           /projectB.jar
   /projectA
       /build/libs/projectA.jar
   /projectB
       /build/libs/projectB.jar

How do I do this ? Any code example? I am using gradle 4.0 if that helps

Depending on what you want to do with all of the libs in the root build directory, this is sort of the same question (with answer): distTar only includes subproject jars on second execution, following a clean