fix: expand a directory passed to targetExclude into the files under it - #3032
Open
jjh75607 wants to merge 2 commits into
Open
fix: expand a directory passed to targetExclude into the files under it#3032jjh75607 wants to merge 2 commits into
jjh75607 wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2667
parseTargetIsExcludehas no branch for Gradle's directory types, so aDirectory,DirectoryProperty, orProvider<Directory>fell through togetProject().files(target)and became a collection holding the directory itself.
target.minus(targetExclude)thenremoved nothing, so excluding a directory silently did nothing.
An excluded directory now contributes the files under it through
getAsFileTree(). Thatkeeps the expansion lazy, which matters here: resolving the collection while the extension
is being configured would freeze the directory listing before the build has produced
anything.
This is deliberately limited to
targetExclude. TheStringbranch above adds.git,.gradle, and build directories to the excludes when it is including, and a bare directorytree carries none of that, so letting
targetaccept a directory would start formattingbuild output and
.gitcontents. The branch already treats including and excludingdifferently for the same reason.
One note on the reproduction. The example in the issue uses
layout.buildDirectory, andwith a
**/-prefixed string target that looks like it already works, because theStringbranch excludes build directories on its own. The scala block in the report has a
src/**-style default target, where nothing masks it. The tests use agenerateddirectoryto stay out of the way of that automatic exclusion.
Tests cover
Directory,DirectoryProperty,Provider<Directory>, and one run with theconfiguration cache enabled. All four fail before the change.