Copy Task From Configuration with Custom Duplicate Handling

Hello,

I have an outgoing configuration that includes a folder as an artifact. When I attempt to copy the artifacts from the resolved configuration, if the folders have the same contents, then Gradle asks for a duplication strategy. I understand the duplication strategy and why its required but if a configuration contains a group of different named folders as artifacts that are named differently then gradle complains when there are no duplicate “paths”, just folders with files in them that might have the same name but different paths. IE the same contents. This should not trigger the duplicate error. Is there a way to copy each artifact into its own directory and not have the duplicate error?

For context I am trying to allow for sharing some files between projects. Projects may provide files and others may consume them. The providers create a folder artifact for the outgoing configuration with a unique name. Consumers can then declare multiple providers they depend on. Its when I attempt to copy the group of artifacts in the configuration in the Consumer project that I get this issue.

For example:

Project A provides folder-a
Project B provides folder-b
Project C consumes project A and B
I would then expect to be able to copy folder-a and folder-b into the Consumer’s build location.

Thanks!

Hard to say without you providing an MCVE, but I guess you are configuring folder-a and folder-b as artifacts which makes their content being published. Instead you most probably want to configure their parent directory as artifact, so that the folders are part of the published structure.

@Vampire Thank you, that was the issue or at least solved my problem.

1 Like