How to remove .gitignore from defaultExcludes for whole multi module project

We have a multi module project and we have a lot of places where .gitignore, .gitattribute files need to be considered as task inputs and outputs. I have observed that gradle by default excludes these patterns(everything in org.apache.tools.ant.DirectoryScanner.DEFAULTEXCLUDES).
To remove .gitignore from the exclusions list, I have tried to add the below line in settings.gradle.kts

org.apache.tools.ant.DirectoryScanner.removeDefaultExclude("**/.gitignore")

The problem is this line seems to be working only from the second build which gets executed on a given gradle daemon process. For the first time build on a newly started daemon the above workaround doesn’t work.

I would like to know if there is any workaround which can be easily applicable for the whole multi module project.

Hi,

I am not sure if there is a workaround right now. You could try if an init script works any better. We have some issues to make default excludes a first-class citizen (e.g. https://github.com/gradle/gradle/issues/11176), though I don’t know when we’ll be able to implement those.

Cheers,
Stefan

Thanks Stefan for the reply.

I have tried to add default exlucdes from init.gradle.kts, Still it doesn’t seem to work for the first build in the daemon. From second build onwards its working.

I have debugged a bit of gradle code and found that org.gradle.internal.service.scopes.VirtualFileSystemServices is the class which is using the default excludes and that seems to initialize even before init.gradle.kts is executed. The object is initialized for each gradle build, so it is working from second build onwards.

Hi Uday,

I just merged a fix which allows to configure default excludes in settings.gradle and those will take effect on the first build already: https://github.com/gradle/gradle/pull/13694 The fix will be in Gradle 6.7.

Cheers,
Stefan

1 Like

Thanks a lot @Stefan_Wolf for the fix. This is much needed for us.
I will try it out once 6.7-RC is released.

Hi @Stefan_Wolf
Tried out 6.7-rc-1, now the fix is working as expected. Thanks a lot for the fix. Appreciate your help.

Cheers,
Uday Shankar