Hello, I’m seeing some peculiar behaviour when upgrading from Gradle 6.x to Gradle 7.x.
We have a product that is a multi-project build, which uses several Gradle plugins that we’ve written.
We’ve upgraded our Gradle version, and have successfully tested the build locally. However, I’m seeing this error in the output of my CI:
15:48:55 FAILURE: Build failed with an exception.
15:48:55
15:48:55 * What went wrong:
15:48:55 Execution failed for task ':some:task:in:multi:project:build:task'
15:48:55 > Cannot change default excludes during the build. They were changed from [**/#*#, **/%*%, **/*~, **/.#*, **/.DS_Store, **/._*, **/.bzr, **/.bzr/**, **/.bzrignore, **/.cvsignore, **/.git, **/.git/**, **/.gitattributes, **/.gitignore, **/.gitmodules, **/.hg, **/.hg/**, **/.hgignore, **/.hgsub, **/.hgsubstate, **/.hgtags, **/.svn, **/.svn/**, **/CVS, **/CVS/**, **/SCCS, **/SCCS/**, **/vssver.scc] to [**/#*#, **/%*%, **/*.iml, **/*~, **/.#*, **/.DS_Store, **/._*, **/.ant-targets-build.xml, **/.bzr, **/.bzr/**, **/.bzrignore, **/.classpath, **/.cvsignore, **/.git, **/.git/**, **/.gitattributes, **/.gitmodules, **/.hg, **/.hg/**, **/.hgignore, **/.hgsub, **/.hgsubstate, **/.hgtags, **/.ivy-eclipse.properties, **/.project, **/.sdk.root, **/.settings/**, **/.svn, **/.svn/**, **/CVS, **/CVS/**, **/SCCS, **/SCCS/**, **/build.gradle.kts, **/build.local.properties, **/build.log, **/default-package-module-pack.xml, **/gbuild/**, **/gradle.properties, **/target/**, **/vssver.scc]. Configure default excludes in the settings script instead.
Investigating that “failed for” task didn’t reveal anything that might explain the error. In fact, there is only one instance across all of our product and plugin codebases of the **/gbuild/**
exclusion that the build is complaining about.
This is in a Gradle plugin that we’ve written in Java, that is used throughout the main multi-project build. The code looks like this:
ConfigurableFileTree fileTree = project.fileTree(project.getProjectDir(), files -> {
files.exclude(
"**/.classpath",
"**/.settings/**",
"**/.project",
"**/.ivy-eclipse.properties",
"**/target/**",
"**/.sdk.root",
"**/build.local.properties",
"**/.ant-targets-build.xml",
"**/build.log",
"**/gbuild/**",
"**/gradle.properties",
"**/build.gradle.kts",
"**/*.iml",
"**/default-package-module-pack.xml"
);
});
This must be the code that is causing the failure, as it’s the only place that these excludes are referred to across the entire collective codebase.
Is this use of a FileTree
object in Java no longer supported by Gradle 7.x? It feels like you should be able to dynamically specify includes/excludes for a specific FileTree
object’s creation, I’m not trying to change any defaults, just augment them. What is the correct way to do this? Any help would be greatly appreciated!
Worth mentioning that I don’t want to update the default in the settings file. This is because these aren’t really new defaults, just something that this one FileTree
creation needs to be aware of. Also, we will eventually want to use this plugin in multiple different product repos, and I don’t want every repo to need the same boilerplate in its settings file.