Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DuplicatesStrategy.FAIL doesn't work with transform #488

Closed
boris-petrov opened this issue May 7, 2019 · 4 comments · Fixed by #1233
Closed

DuplicatesStrategy.FAIL doesn't work with transform #488

boris-petrov opened this issue May 7, 2019 · 4 comments · Fixed by #1233
Labels

Comments

@boris-petrov
Copy link

I have something along the lines of:

task foo(type: ShadowJar, dependsOn: fooClasses) {
	from sourceSets.foo.output

	configurations = [project.configurations.fooRuntimeClasspath]

	archiveBaseName = 'foo'
	zip64 = true

	mergeServiceFiles()
	mergeGroovyExtensionModules()
	transform(AppendingTransformer) {
		resource = 'META-INF/extensions.idx'
	}

	duplicatesStrategy = DuplicatesStrategy.FAIL
}

There are multiple META-INF/extensions.idx files which, when duplicatesStrategy is NOT DuplicatesStrategy.FAIL, get merged correctly but when it IS DuplicatesStrategy.FAIL - it blows up with org.gradle.api.file.DuplicateFileCopyingException: Encountered duplicate path "META-INF/extensions.idx" during copy operation configured with DuplicatesStrategy.FAIL. Am I doing something wrong or is this a bug? I think that having specified that I want those files appended means that it should not blow up with that error, right?

@Gamebuster19901
Copy link

I'm having the opposite problem. When I set duplicatesStrategy = DuplicatesStrategy.INCLUDE, duplicates are not included in the shadowed jar.

@Goooler
Copy link
Member

Goooler commented Jan 25, 2025

It's the correct behavior from Gradle side.

Throw a DuplicateFileCopyingException when subsequent items are to be created at the same path.
Use this strategy when duplicates are an error condition that should cause the build to fail.

https://docs.gradle.org/current/javadoc/org/gradle/api/file/DuplicatesStrategy.html#FAIL

@Goooler Goooler closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2025
@boris-petrov
Copy link
Author

@Goooler thanks for the response. I understand what DuplicatesStrategy.FAIL means but in this case it's not so straight-forward. After all, I've specified a transformer that appends files with the same name. Similar with mergeServiceFiles - does it make sense to have mergeServiceFiles and DuplicatesStrategy.FAIL and that to blow up when there are multiple service-files? Well, no, as I've explicitly requested they to be merged. Same with an AppendingTransformer - I want all META-INF/extensions.idx files to be appended - why would it blow up when there's more than one?

@Goooler
Copy link
Member

Goooler commented Feb 6, 2025

You are right, I can repro this in #1233.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants