Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
chore: merge upstream branch gradle/master into main
Browse files Browse the repository at this point in the history
This commit synchronizes the latest 11 changes from the https://github.com/gradle/gradle/tree/master. The changes include:

ad1c6ad: gradle/gradle#26452 Fix order dependency in excluded group
693b1f1: Merge branch 'master' into fix_order_dependency
a242c17: Merge branch 'master' into fix_order_dependency
c6e9e4a: removed redundant casting
561ea62: suppressed warnings
b0c7f87: changed defaultExcludes and previousDefaultExcludes to HashSet
29124c7: Merge branch 'gradle:master' into fix_order_dependency
89a7e33: Merge branch 'master' into fix_order_dependency
662db14: Merge branch 'master' into fix_order_dependency
2e100cd: Merge branch 'master' into fix_order_dependency
8f81165: fixed order dependency in excluded group
  • Loading branch information
meowool-bot committed Nov 27, 2023
2 parents 3c0e58b + ad1c6ad commit 2027fe7
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import java.util.Collection;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* The basic implementation for converting {@link PatternSet}s to {@link Spec}s.
Expand All @@ -46,7 +48,7 @@
@ServiceScope(Scope.Global.class)
public class PatternSpecFactory implements FileSystemDefaultExcludesListener {
public static final PatternSpecFactory INSTANCE = new PatternSpecFactory();
private String[] previousDefaultExcludes;
private Set<String> previousDefaultExcludes = new HashSet<String>();
private final Map<CaseSensitivity, Spec<FileTreeElement>> defaultExcludeSpecCache = new EnumMap<>(CaseSensitivity.class);

@Override
Expand Down Expand Up @@ -88,7 +90,7 @@ public Spec<FileTreeElement> createExcludeSpec(PatternSet patternSet) {
}

private synchronized Spec<FileTreeElement> getDefaultExcludeSpec(CaseSensitivity caseSensitivity) {
String[] defaultExcludes = DirectoryScanner.getDefaultExcludes();
Set<String> defaultExcludes = new HashSet<String>(Arrays.asList(DirectoryScanner.getDefaultExcludes()));
if (defaultExcludeSpecCache.isEmpty()) {
updateDefaultExcludeSpecCache(defaultExcludes);
} else if (invalidChangeOfExcludes(defaultExcludes)) {
Expand All @@ -98,29 +100,29 @@ private synchronized Spec<FileTreeElement> getDefaultExcludeSpec(CaseSensitivity
return defaultExcludeSpecCache.get(caseSensitivity);
}

private boolean invalidChangeOfExcludes(String[] defaultExcludes) {
return !Arrays.equals(previousDefaultExcludes, defaultExcludes);
private boolean invalidChangeOfExcludes(Set<String> defaultExcludes) {
return !previousDefaultExcludes.equals(defaultExcludes);
}

private void failOnChangedDefaultExcludes(String[] excludesFromSettings, String[] newDefaultExcludes) {
List<String> sortedExcludesFromSettings = Arrays.asList(excludesFromSettings);
private void failOnChangedDefaultExcludes(Set<String> excludesFromSettings, Set<String> newDefaultExcludes) {
List<String> sortedExcludesFromSettings = new ArrayList<String>(excludesFromSettings);
sortedExcludesFromSettings.sort(Comparator.naturalOrder());
List<String> sortedNewExcludes = Arrays.asList(newDefaultExcludes);
List<String> sortedNewExcludes = new ArrayList<String>(newDefaultExcludes);
sortedNewExcludes.sort(Comparator.naturalOrder());
throw new InvalidUserCodeException(String.format("Cannot change default excludes during the build. They were changed from %s to %s. Configure default excludes in the settings script instead.", sortedExcludesFromSettings, sortedNewExcludes));
}

public synchronized void setDefaultExcludesFromSettings(String[] excludesFromSettings) {
if (!Arrays.equals(previousDefaultExcludes, excludesFromSettings)) {
updateDefaultExcludeSpecCache(excludesFromSettings);
Set<String> excludesFromSettingsSet = new HashSet<String>(Arrays.asList(excludesFromSettings));
if (!previousDefaultExcludes.equals(excludesFromSettingsSet)) {
updateDefaultExcludeSpecCache(excludesFromSettingsSet);
}
}

private void updateDefaultExcludeSpecCache(String[] defaultExcludes) {
private void updateDefaultExcludeSpecCache(Set<String> defaultExcludes) {
previousDefaultExcludes = defaultExcludes;
List<String> patterns = Arrays.asList(defaultExcludes);
for (CaseSensitivity caseSensitivity : CaseSensitivity.values()) {
defaultExcludeSpecCache.put(caseSensitivity, createSpec(patterns, false, caseSensitivity.isCaseSensitive()));
defaultExcludeSpecCache.put(caseSensitivity, createSpec(defaultExcludes, false, caseSensitivity.isCaseSensitive()));
}
}

Expand Down

0 comments on commit 2027fe7

Please sign in to comment.