Make plugin-management repositories in the init script configurable#59
Merged
Conversation
Today, the testkit-injected init script always falls back to gradlePluginPortal() for plugins not in the on-disk integration repo. Projects with strict policies against the public Plugin Portal — e.g. those that resolve everything through an internal Maven mirror — can't opt out without forking testkit. Add `pluginRepositories` to `TestkitExtension`. When non-empty, the listed Maven URLs replace gradlePluginPortal() in the generated init script. When empty (the default), behavior is unchanged. Wired through as a new `testkit-plugin-repositories` system property on the Test task, consumed by TestProjectExtension when emitting the pluginManagement.repositories block.
Removed the comment block explaining the pluginRepositories property.
ogolberg
approved these changes
May 21, 2026
# Conflicts: # junit5/src/main/kotlin/com/toasttab/gradle/testkit/TestProjectExtension.kt
andrewparmet
added a commit
that referenced
this pull request
May 25, 2026
…urable (#59) (#63) Reverts #59. `extension.pluginRepositories.getOrElse(emptyList())` is read inside the `tasks.named<Test>(\"test\") { ... }` configuration block. When the test task gets realized eagerly (e.g. by \`kotlin-dsl\` configuring its test source set during plugin application), the extension's `ListProperty` hasn't been mutated by the user's \`configure<TestkitExtension> { pluginRepositories.add(...) }\` block yet, so we read an empty list, never set the system property, and the init script falls back to `gradlePluginPortal()`. Downstream configured `testkitTests.pluginRepositories` and the resulting init script still contained `gradlePluginPortal()` instead of the configured URL. A correct implementation might defer the read to task execution time using `jvmArgumentProviders.add { ... }` or `Provider.map { ... }`.
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
Today the testkit-injected init script always uses
gradlePluginPortal()for plugins not in the on-disk integration repo. Projects can't opt out of hitting the public rate-limiting repos.This PR adds
pluginRepositoriestoTestkitExtension. When non-empty, the listed Maven URLs replacegradlePluginPortal()in the generated init script. When empty (the default), behavior is unchanged.testkitTests { pluginRepositories.add("https://nexus.example.com/repository/gradle-plugins/") }Wired through as a new
testkit-plugin-repositoriessystem property on theTesttask, consumed byTestProjectExtensionwhen emitting thepluginManagement.repositoriesblock.