Issue #980: Replace AntBuilder.copy() with Files.walkFileTree()#1006
Conversation
checkstyle-tester/diff.groovy
Outdated
| FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { | ||
|
|
||
| if (vcsDirectories.contains(dir.fileName?.toString())) { | ||
| return FileVisitResult.SKIP_SUBTREE |
There was a problem hiding this comment.
Can we copy all files as is ?
Copy code should be simple copy without any context.
There was a problem hiding this comment.
I added the VCS exclusions (.git, .svn, etc.) to match the original AntBuilder.copy() behavior, which applies Ant's "defaultexcludes" by default. Without these exclusions, we would copy .git/ directories and other VCS artifacts like .gitignore, .gitattributes, which is unnecessary since these files are not needed for Checkstyle analysis. However, if you prefer a simpler copy without context, I can remove these exclusions.
There was a problem hiding this comment.
Can you share link to any implementation?
There was a problem hiding this comment.
I do not see that need some filtering out, we just copy folders, extra hidden folders to copy should be ok
There was a problem hiding this comment.
Official Ant Documentation: https://ant.apache.org/manual/dirtasks.html#defaultexcludes
Ant Source Code (DirectoryScanner.java):
https://github.com/apache/ant/blob/f862774a9e2d2afe3d25d7116f0672eeb4f3e9bf/src/main/org/apache/tools/ant/DirectoryScanner.java#L170
When Copy.java needs to copy files, it calls FileSet.getDirectoryScanner() to get the list of files. Internally, FileSet creates a DirectoryScanner which automatically calls addDefaultExcludes() to add VCS patterns to its exclude list. The scanner then returns only non-excluded files to Copy, so VCS directories are never copied.
There was a problem hiding this comment.
I do not see that need some filtering out, we just copy folders, extra hidden folders to copy should be ok
Will update accordingly..
41f387f to
3349663
Compare
|
lets try one more time .... |
|
triggered checkstyle/checkstyle#18312 (comment) |
|
triggered checkstyle/checkstyle#17575 (comment) |
|
CI is tested at checkstyle/checkstyle#18184 (review) Works well. |
|
This time all works. |
Issue #980:
What is fixed:
targetDir.startsWith(sourceDir)→dir.startsWith(destinationDir)since some of the valid directories were getting skipped which caused ci errors.Why earlier code failed:
Improvements:
.git,.svn,.hg,CVS, etc.).gitignore,.gitattributes, etc.)defaultexcludesbehavior