Skip to content

Add hidden sbt key for extra JUnit template library dependencies #SCL-25373 - #148

Merged
Vasil Vasilev (vasilmkd) merged 4 commits into
masterfrom
scl-25373-junit-template-library-deps
Apr 29, 2026
Merged

Add hidden sbt key for extra JUnit template library dependencies #SCL-25373#148
Vasil Vasilev (vasilmkd) merged 4 commits into
masterfrom
scl-25373-junit-template-library-deps

Conversation

@vasilmkd

Copy link
Copy Markdown
Contributor

Summary

Introduces a new hidden setting key, intellijExtraJUnitTemplateLibraryDependencies: SettingKey[Seq[ModuleID]], that lets a consuming build add library dependencies that should appear only on the JUnit
Run Configuration template classpath generated during IDEA project import — not on the sbt Test / fullClasspath.

Motivation: when tests are launched from the IDE, some libraries are needed at runtime that are otherwise satisfied differently during in-sbt test runs (e.g. provided by the IntelliJ instance or by an
upstream module). Until now there was no way to express "extra JAR for the IDE-launched test JVM only" without polluting Test / fullClasspath.

Implementation

  • New settingKey[Seq[ModuleID]] intellijExtraJUnitTemplateLibraryDependencies (Keys.scala), hidden via KeyRanks.Invisible — settable from build.sbt but not surfaced in tab-completion / tasks
    listings.
  • New private[sbtidea] Ivy Configuration intellijJUnitTemplateConfig (hidden, no parents). The key's modules are routed into this configuration via libraryDependencies ++= … .map(_ % intellijJUnitTemplateConfig) in Init.scala, so they participate in normal update resolution but do not leak into Compile/Test.
  • TestClasspathTasks.fullTestClasspathForJUnitTemplate now appends Classpaths.managedJars(intellijJUnitTemplateConfig, classpathTypes.value, update.value) to the template classpath.
    fullTestClasspathForSbt is intentionally untouched.

Test plan

  • New integration test intellijExtraJUnitTemplateLibraryDependencies appears only on the JUnit template classpath in SbtIdeaPluginIntegrationTest.scala. It:
    1. configures intellijExtraJUnitTemplateLibraryDependencies += "commons-io" % "commons-io" % "2.16.1" against the simple-with-plugin fixture,
    2. runs createIDEARunConfiguration and asserts commons-io-2.16.1.jar is present in the generated .idea/runConfigurations/junit_template_argfile.txt,
    3. runs show Test/fullClasspath and asserts the same jar is absent from the captured stdout.
  • Manually verified via publishLocal against the Scala Plugin repo.

…-25373

Introduce intellijExtraJUnitTemplateLibraryDependencies, a hidden
settingKey[Seq[ModuleID]] whose modules are resolved through a dedicated
hidden Ivy configuration and appended only to the JUnit Run Configuration
template classpath. The sbt Test classpath is intentionally unaffected,
so libraries needed at test runtime when launched from the IDE can be
declared without polluting in-sbt test runs.

Covered by a new integration test that asserts the resolved jar appears
in the generated junit_template_argfile.txt and is absent from
Test/fullClasspath.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
actions/checkout v4 -> v6
actions/setup-java v4 -> v5
coursier/cache-action v6 -> v8

sbt/setup-sbt is already at the latest major (v1).
Existing inputs are unchanged across these majors, so no
further configuration edits are needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
sbt-ci-release   1.11.1 -> 1.11.2
sbt-ide-settings 1.1.2  -> 1.1.4

Verified via sbt reload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.11.5 -> 1.12.10. Verified via sbt reload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vasilmkd
Vasil Vasilev (vasilmkd) merged commit 4a48c34 into master Apr 29, 2026
1 check passed
@vasilmkd
Vasil Vasilev (vasilmkd) deleted the scl-25373-junit-template-library-deps branch April 29, 2026 12:09
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