Skip to content

Issue #980: Replace AntBuilder.copy() with Files.walkFileTree()#1003

Merged
romani merged 1 commit into
checkstyle:masterfrom
vivek-0509:refactorAntBuilderCopy
Dec 26, 2025
Merged

Issue #980: Replace AntBuilder.copy() with Files.walkFileTree()#1003
romani merged 1 commit into
checkstyle:masterfrom
vivek-0509:refactorAntBuilderCopy

Conversation

@vivek-0509

Copy link
Copy Markdown
Member

Issue #980:

Description

Replaces the AntBuilder.copy() implementation in copyDir with Java NIO's Files.walkFileTree() and SimpleFileVisitor. This addresses the issues that caused PR #982 to be reverted.

Changes

  • Replaced AntBuilder.copy(todir: destination) { fileset(dir: source) } with Files.walkFileTree() and SimpleFileVisitor
  • Added proper infinite recursion prevention by:
    1. Skipping directories that are inside the destination
    2. Skipping directories/files whose target would end up inside the source (prevents nested copies when destination is inside source)

Note on Symlinks

The implementation does not follow directory symlinks by default. This is intentional:

  • All symlinks in tested repos point to directories already within the same repository
  • Not following them avoids copying the same files twice

Closes #980

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lets try in real execution

@romani romani merged commit be967ba into checkstyle:master Dec 26, 2025
9 checks passed
@romani

romani commented Dec 26, 2025

Copy link
Copy Markdown
Member

triggered at checkstyle/checkstyle#17575 (comment)

@romani

romani commented Dec 26, 2025

Copy link
Copy Markdown
Member

triggered at checkstyle/checkstyle#18312 (comment)

@romani

romani commented Dec 26, 2025

Copy link
Copy Markdown
Member

update works fine !!!

@vivek-0509 , 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.

Refactor AntBuilder to Groovy's built-in file operations

2 participants