Skip to content

Conversation

@vivek-0509
Copy link
Contributor

@vivek-0509 vivek-0509 commented Dec 26, 2025

Issue #980:

What is fixed:

  • Changed targetDir.startsWith(sourceDir)dir.startsWith(destinationDir) since some of the valid directories were getting skipped which caused ci errors.

Why earlier code failed:

  • Previous check skipped directories when dest was inside source
  • Caused missing files and CI build failures

Improvements:

  • NOT Added VCS directory excludes (.git, .svn, .hg, CVS, etc.)
  • NOT Added VCS file excludes (.gitignore, .gitattributes, etc.)
  • NOT Matches AntBuilder's defaultexcludes behavior

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question

FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {

if (vcsDirectories.contains(dir.fileName?.toString())) {
return FileVisitResult.SKIP_SUBTREE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we copy all files as is ?
Copy code should be simple copy without any context.

Copy link
Contributor Author

@vivek-0509 vivek-0509 Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share link to any implementation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see that need some filtering out, we just copy folders, extra hidden folders to copy should be ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see that need some filtering out, we just copy folders, extra hidden folders to copy should be ok

Will update accordingly..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vivek-0509 vivek-0509 force-pushed the issue-980-refactorAntBuilderCopy branch from 41f387f to 3349663 Compare December 26, 2025 21:50
@romani romani merged commit 4a316ae into checkstyle:master Dec 27, 2025
9 checks passed
@romani
Copy link
Member

romani commented Dec 27, 2025

lets try one more time ....

@romani
Copy link
Member

romani commented Dec 27, 2025

triggered checkstyle/checkstyle#18312 (comment)

@romani
Copy link
Member

romani commented Dec 27, 2025

triggered checkstyle/checkstyle#17575 (comment)

@romani
Copy link
Member

romani commented Dec 27, 2025

CI is tested at checkstyle/checkstyle#18184 (review)

Works well.

@romani
Copy link
Member

romani commented Dec 27, 2025

This time all works.
Thanks a lot!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants