Package com.intsof.ai.build.integrity
Class GitIgnoreAwareFileVisitor
- java.lang.Object
-
- java.nio.file.SimpleFileVisitor<Path>
-
- com.intsof.ai.build.integrity.GitIgnoreAwareFileVisitor
-
- All Implemented Interfaces:
FileVisitor<Path>
public abstract class GitIgnoreAwareFileVisitor extends SimpleFileVisitor<Path>
Shared recursive file visitor that enforces generic traversal behaviors, such as evaluating static `skipDirs` and dynamically parsing and enforcing local `.gitignore` rules in real-time.
-
-
Constructor Summary
Constructors Constructor Description GitIgnoreAwareFileVisitor(Path basePath, boolean gitignoreAutoExclude, Set<String> skipDirNames, List<PathMatcher> forceIncludeMatchers, org.apache.maven.plugin.logging.Log log)Constructs a new visitor with the specified configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanisIgnoredByGit(Path file)Let subclass mojos efficiently check if a matched file is globally ignored by Git.FileVisitResultpostVisitDirectory(Path dir, IOException exc)FileVisitResultpreVisitDirectory(Path dir, BasicFileAttributes attrs)-
Methods inherited from class java.nio.file.SimpleFileVisitor
visitFile, visitFileFailed
-
-
-
-
Constructor Detail
-
GitIgnoreAwareFileVisitor
public GitIgnoreAwareFileVisitor(Path basePath, boolean gitignoreAutoExclude, Set<String> skipDirNames, List<PathMatcher> forceIncludeMatchers, org.apache.maven.plugin.logging.Log log)
Constructs a new visitor with the specified configuration.- Parameters:
basePath- the base directory being scannedgitignoreAutoExclude- whether to automatically read and apply .gitignore rulesskipDirNames- a set of directory names to always skip (e.g. "target", ".git")forceIncludeMatchers- a list of matchers for files that must be included regardless of exclusionslog- the Maven logger
-
-
Method Detail
-
preVisitDirectory
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException
- Specified by:
preVisitDirectoryin interfaceFileVisitor<Path>- Overrides:
preVisitDirectoryin classSimpleFileVisitor<Path>- Throws:
IOException
-
postVisitDirectory
public FileVisitResult postVisitDirectory(Path dir, IOException exc)
- Specified by:
postVisitDirectoryin interfaceFileVisitor<Path>- Overrides:
postVisitDirectoryin classSimpleFileVisitor<Path>
-
isIgnoredByGit
protected boolean isIgnoredByGit(Path file)
Let subclass mojos efficiently check if a matched file is globally ignored by Git.- Parameters:
file- the path to check- Returns:
- true if the file is ignored by any .gitignore rule in the current traversal stack
-
-