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

Setting sourceSets resource config srcDir property in build script causes build failure due to duplicateStrategy in Windows #27103

Closed
psvkushal opened this issue Nov 20, 2023 · 5 comments
Labels
closed:duplicate Duplicated or superseeded by another issue

Comments

@psvkushal
Copy link

psvkushal commented Nov 20, 2023

Current Behavior

In windows 11, with gradle 7.6.1

sourceSets { main { resources { srcDir 'src/main/resources' } } }
When the above property is set and there are any files present in the srcDir location, then build failure occurs with the following message

Task :app:processResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:processResources'.

Entry testingFile.txt is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.6.1/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

The build failure could be resolved with commenting out srcDir (since this is a default value) or setting duplicateStrategy to any of the available values.

Expected Behavior

The build script should have been executed without any issue. without the need to set duplicateStrategy or commenting out the srcDir

Context (optional)

https://discuss.gradle.org/t/using-sourcesets-along-with-jar-task-in-gradle-build-causing-build-failure-in-windows-due-to-duplicatestrategy-not-being-set/47034
The discussion related to this bug has occurred in the gradle forum which might give additional context.

Steps to Reproduce

mentioned in this repo
https://github.com/psvkushal/gradle-sourceSets-buildFailure-Windows

Gradle version

7.6.1

Build scan URL (optional)

No response

Your Environment (optional)

Windows 11, the issue is not occurring in macOS

@cobexer
Copy link
Member

cobexer commented Nov 21, 2023

Thank you for your interest in Gradle!

This issue will be closed as a duplicate of

Please add your use case and 👍 to that issue.


srcDir is additive, you should use setSrcDirs to override the default value.

@cobexer cobexer closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2023
@cobexer cobexer added closed:duplicate Duplicated or superseeded by another issue and removed a:bug to-triage labels Nov 21, 2023
@psvkushal
Copy link
Author

Hi @cobexer if possible can you elaborate on what would additive here would mean here? or point me to any resource where this is mentioned in context to srcDir?
Main issue here is I need to do case handling when I am working with windows which is not required for macOS any reason for difference in behaviour between the 2 OS? I was not able to get any answer in the forum so asking the question here it self.

@cobexer
Copy link
Member

cobexer commented Dec 22, 2023

Sorry for the late reply!

From the Javadoc:

Adds the given source directory to this set.

And for:

Main issue here is I need to do case handling when I am working with windows which is not required for macOS any reason for difference in behaviour between the 2 OS?

I don't see how Windows and Mac OS would differ here since both default to case-insensitive filesystems. If you do see different behavior and can create a reproducer, please file that as a separate issue.

@lapo-luchini
Copy link

srcDir is additive, you should use setSrcDirs to override the default value.

Just in case anyone is puzzled by this as I was, I found an example to do that (in either Kotlin or Groovy) in this URL:

srcDirs = [ 'src/main/resources' ]

@psvkushal
Copy link
Author

@cobexer I am sorry it took me some time, but I raised a seperate issue here #27685.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:duplicate Duplicated or superseeded by another issue
Projects
None yet
Development

No branches or pull requests

3 participants