Resolve duplicates when copying dependencies

Hello there. I found a lot of ‘How to copy dependencies to a directory?’ topics but they do not cover one critical issue so here we are again (mentioned topics are locked so I cannot ask there).

TL;DR
How should I go about jar files of the same name but different content?

Full story
Consider following build.gradle file.

apply plugin: 'java'

dependencies {
	compile group: 'android.arch.lifecycle', name: 'common',  version: '1.1.1'
	compile group: 'android.arch.lifecycle', name: 'runtime', version: '1.1.1'
}

repositories {
	maven {
		url "https://maven.google.com/"
	}
}

task getDeps(type: Copy) {
	from sourceSets.main.runtimeClasspath
	into 'deps/'
	duplicatesStrategy 'warn'
}

When getDeps task is executed the ouput is:

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:getDeps
Encountered duplicate path "common-1.1.1.jar" during copy operation configured with DuplicatesStrategy.WARN

BUILD SUCCESSFUL

Total time: 8.662 secs

Running gradle with dependencies argument gives:

runtime - Runtime dependencies for source set 'main'.
+--- android.arch.lifecycle:common:1.1.1
|    \--- com.android.support:support-annotations:26.1.0
\--- android.arch.lifecycle:runtime:1.1.1
     +--- android.arch.lifecycle:common:1.1.1 (*)
     +--- android.arch.core:common:1.1.1
     |    \--- com.android.support:support-annotations:26.1.0
     \--- com.android.support:support-annotations:26.1.0

The problem is that two groups (android.arch.lifecycle and android.arch.core) have artifacts of name common-1.1.1.jar. The contents of these files are different of course so I need both of them. How should I go about that? Can group id be included in filename to avoid duplicate names? Or maybe jar files could be merged during copying to have two sets of clasess?

Thank you!

UPDATE
Based on this answer from StackOverflow I modified my build.gradle to prepend artifact names with group id:

apply plugin: 'java'

dependencies {
	compile group: 'android.arch.lifecycle', name: 'common',  version: '1.1.1'
	compile group: 'android.arch.lifecycle', name: 'runtime', version: '1.1.1'
}

repositories {
	maven {
		url "https://maven.google.com/"
	}
}

task getDeps {
    inputs.files configurations.compile
    outputs.dir "deps"
    doLast {
        mkdir "deps"
        delete fileTree(dir: "deps" , include: "**/*")
        ResolvedConfiguration rc = configurations.compile.resolvedConfiguration
        Set<ResolvedArtifact> artifacts = rc.resolvedArtifacts
        artifacts.each { ra ->
            ModuleVersionIdentifier mvi = ra.moduleVersion.id
            copy {
                from ra.file
                into "deps"
                duplicatesStrategy 'fail'
                rename { old ->
                    return "${mvi.group}-${mvi.name}-${ra.classifier}-${mvi.version}.${ra.extension}"
                }
            }
        }
    }
}

Is it reliable solution? Are there other caveats? Do I really need this ra.classifier which always seems to be null?