Skip to content

Move test project token replacement to TestProjectExtension#54

Open
ogolberg wants to merge 6 commits into
mainfrom
move-token-replacement-to-extension
Open

Move test project token replacement to TestProjectExtension#54
ogolberg wants to merge 6 commits into
mainfrom
move-token-replacement-to-extension

Conversation

@ogolberg

@ogolberg ogolberg commented May 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Drop the copyTestProjects task and its Ant ReplaceTokens filter; TestProjectExtension now copies test projects straight from src/test/projects into its temp dir and substitutes tokens in place using Apache Commons Text (preserving the @TOKEN@ syntax).
  • Plugin registers writeTestkitTokens, which serializes the merged token map (user tokens + built-ins: TESTKIT_PLUGIN_VERSION, TESTKIT_INTEGRATION_REPO, VERSION) to build/testkit/tokens.properties and passes the path via the new testkit-tokens system property.
  • Per-version @GradleVersion(properties = [...]) values are layered on top of the file tokens at substitution time, so per-Gradle-version replacements work out of the box.

ogolberg added 6 commits May 11, 2026 10:22
The testkit plugin previously used a Copy task with Ant ReplaceTokens to
filter test projects into build/test-projects before TestProjectExtension
copied them again into a temporary directory. This commit removes the
intermediate copy: TestProjectExtension now copies straight from the
source tree and performs token substitution in place using Apache Commons
Text's StringSubstitutor (keeping the existing @token@ syntax).

Tokens are passed to the extension via a properties file written by the
plugin's writeTestkitTokens task (testkit-tokens system property).
Per-version @GradleVersion(properties = [...]) values are layered on top
at test-execution time and used as additional replacement tokens.

Generated with Claude Code
Commons Text's StringSubstitutor required reading each file fully into
memory. Switch to plexus-interpolation's MultiDelimiterInterpolatorFilterReader,
which streams through a FilterReader (the same shape Ant's ReplaceTokens
and Gradle's filter<ReplaceTokens> use). Use ISO-8859-1 for read/write so
binary files in test projects pass through byte-for-byte; ASCII @key@
tokens still match.

Generated with Claude Code
…e as a test input

Also declare tokensFile as an input of the test task so that a token change
invalidates the test task on its own, even when the source projects tree is
unchanged.

Generated with Claude Code
Generated with Claude Code
Replace the copy-then-walk-then-rewrite pipeline with a single
copyToRecursively pass whose copyAction streams each regular file through
the InterpolatorFilterReader straight to its destination. Removes the
second filesystem walk and the .tokens.tmp rename per file.

Generated with Claude Code
…t-to-extension

# Conflicts:
#	junit5/src/main/kotlin/com/toasttab/gradle/testkit/TestProjectExtension.kt
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.

1 participant