Copy order and DuplicatesStrategy.EXCLUDE

(onyn) #1

As stated in documentation, DuplicatesStrategy.EXCLUDE strategy “will leave the file/entry that was first copied/created in place”. But how order is calculated? Which of them would be the first?

In my case I have reference jar in which I want to patch and replace several classes, so my task looks like below:

task buildPatch(type: Jar, dependsOn: "build") {
	classifier = "patch"
	duplicatesStrategy = DuplicatesStrategy.EXCLUDE
	from sourceSets.patch.output
	from zipTree('lib/reference.jar')

How can I guarantee that files would come from sourceSets.patch.output first? Or how to explicitly set copy order if I add more locations to copy from? I don’t want to rely on unclear algorithm that may change in the future.