-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default exclude src/main and src/test folders.
- Loading branch information
Showing
6 changed files
with
127 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
71 changes: 71 additions & 0 deletions
71
...in/src/main/java/com/link_intersystems/gradle/plugins/multimodule/PatternPathExclude.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.link_intersystems.gradle.plugins.multimodule; | ||
|
||
import java.nio.file.FileSystem; | ||
import java.nio.file.FileSystems; | ||
import java.nio.file.Path; | ||
import java.nio.file.PathMatcher; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.function.Predicate; | ||
|
||
class PatternPathExclude implements Predicate<Path> { | ||
|
||
private final List<String> appliedPaths = new ArrayList<>(); | ||
private final List<String> ignoredPaths = new ArrayList<>(); | ||
private List<String> excludePaths; | ||
private List<PathMatcher> excludedPaths; | ||
|
||
public PatternPathExclude() { | ||
excludePaths = new ArrayList<>(); | ||
} | ||
|
||
public PatternPathExclude(List<String> excludePaths) { | ||
this.excludePaths = excludePaths; | ||
} | ||
|
||
|
||
public void setExcludePaths(List<String> excludePaths) { | ||
this.excludePaths = new ArrayList<>(excludePaths); | ||
excludedPaths = null; | ||
} | ||
|
||
private void ensureInitialized() { | ||
if (excludedPaths == null) { | ||
excludedPaths = new ArrayList<>(); | ||
FileSystem fileSystem = FileSystems.getDefault(); | ||
for (String excludePath : excludePaths) { | ||
try { | ||
if (!excludePath.startsWith("regex:") && !excludePath.startsWith("glob:")) { | ||
excludePath = "glob:" + excludePath; | ||
} | ||
PathMatcher pathMatcher = fileSystem.getPathMatcher(excludePath); | ||
excludedPaths.add(pathMatcher); | ||
appliedPaths.add(excludePath); | ||
} catch (Exception e) { | ||
ignoredPaths.add(excludePath); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public List<String> getAppliedPaths() { | ||
ensureInitialized(); | ||
return appliedPaths; | ||
} | ||
|
||
public List<String> getIgnoredPaths() { | ||
ensureInitialized(); | ||
return ignoredPaths; | ||
} | ||
|
||
@Override | ||
public boolean test(Path path) { | ||
ensureInitialized(); | ||
for (PathMatcher excludedPath : excludedPaths) { | ||
if (excludedPath.matches(path)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
50 changes: 0 additions & 50 deletions
50
...java/com/link_intersystems/gradle/plugins/multimodule/PropertiesExcludePathPredicate.java
This file was deleted.
Oops, something went wrong.
This file contains 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