Gradle - How to append multiple files with same name and path when building jar?

I’m trying to build a jar from my build.gradle file with the following jar task, trying to include all dependencies:

jar {
zip64 true
doFirst {
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

Basically I suspect I need to concatenate the content from a file in the root of this resulting jar called references.conf. As it seems this file comes from other different dependencies and jars I’m not sure if it’s being overwritted or simply ignored. How could I tell gradle in this task to as a duplicate strategy for this specific file to solved as a concatenation of contents from the files that match such name and path?