Move test project token replacement to TestProjectExtension#54
Open
ogolberg wants to merge 6 commits into
Open
Move test project token replacement to TestProjectExtension#54ogolberg wants to merge 6 commits into
ogolberg wants to merge 6 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
copyTestProjectstask and its AntReplaceTokensfilter;TestProjectExtensionnow copies test projects straight fromsrc/test/projectsinto its temp dir and substitutes tokens in place using Apache Commons Text (preserving the@TOKEN@syntax).writeTestkitTokens, which serializes the merged token map (user tokens + built-ins:TESTKIT_PLUGIN_VERSION,TESTKIT_INTEGRATION_REPO,VERSION) tobuild/testkit/tokens.propertiesand passes the path via the newtestkit-tokenssystem property.@GradleVersion(properties = [...])values are layered on top of the file tokens at substitution time, so per-Gradle-version replacements work out of the box.