This message was deleted.
# community-support
s
This message was deleted.
p
As a workaround I use a custom task coping the files manually with
InputChanges
and checking for
caches${File.separatorChar}modules-2${File.separatorChar}files-2.1
, I just hope this (strange) path is stable...
Copy code
@get:InputFiles
@get:Incremental
@get:Classpath
abstract val libs: ConfigurableFileCollection
v
You could do the same with a
CopySpec
, for example using
eachFile { ... }
. The path you are checking is stable as long as you stay within the same Gradle version. But I think it is an implementation detail and could change with any minor version, for example if they feel the need to change the structure of those cache directories again, which is why they are versioned.
Actually, imho you should live with the names as they are, unless you have an actual conflict and if you have a conflict, then just rename one of them explicitly.
p
How can you rename the module names of external dependencies explicitly?
But thanks, will try the copySpec
I think, I found a better solution using artifactView:
Copy code
val resourcesJars: Provider<ResolvableConfiguration>
val nameAndFiles: Provider<Map<String, File>> = resourcesJars.flatMap { it.incoming.artifacts.resolvedArtifacts }.map {
  it.associateBy({
    val owner = it.variant.owner
    if (owner is ModuleComponentIdentifier) {
      "${owner.group}.${owner.module}.${owner.version}.jar"
    } else {
      it.file.name
    }
  }) {
    it.file
  }
})
v
How can you rename the module names of external dependencies explicitly?
I still meant in some copy-spec. Or actually maybe better using some artifact transform.
I think, I found a better solution using artifactView:
Why do you use an artifact view while not changing anything in the view? That seems quite useless. Just
.incoming.artifacts
should do the same.
p
I still meant in some copy-spec.
But how do I get the gav/the id in a copy-spec? EachFile still returns the (unstable) cache file path.
Just .incoming.artifacts should do the same.
Oh yes, forgot to remove it after my experiments.
v
But how do I get the gav/the id in a copy-spec? EachFile still returns the (unstable) cache file path.
Sure, same as with the logic you came up with. You just asked whether you can do it with a
CopySpec
instead of with a custom task with
InputChanges
and you can.
And even with the artifact transform solution, you would need to build the mapping somehow.