Collect jar files accross multiple projects

Hi everybody, I have several subprojects with the following directory structure:

  1. Root
    1.1 Project A
    1.2 Project B
    1.3 Directory X
    1.3.1 Project C
    1.3.2 Project D
    1.3.3 …

I would like to collect all the jars from the projects inside Directory X in a folder distribution/directoryx. Does anyone know how I could achieve this? I already found out how I can get all the jars but I would like to exclude the directory structure. Just the plain jar files in the root directory.

task copyPlugins(type: Copy) {
from fileTree("plugins/").files
into project.file('distribution/plugins')
exclude '**/*-sources.jar'
include '**/*.jar'
includeEmptyDirs = false
}

Any help would be greatly appreciated.

EDIT: found it. I changed the above code to use a fileTree. Sorry for the spam :slight_smile: