Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregated tasks try Configurations from wrong projects when crossScalaVersions are mixed #6272

Open
ches opened this issue Jan 20, 2021 · 2 comments

Comments

@ches
Copy link
Contributor

ches commented Jan 20, 2021

(Triage: can be labelled area/cross_building)

Another stateful cross-building issue, everyone's favorite kind by now? 馃槄

This is somewhat like #5497 except a Configuration is tried that should not be, rather than a cross version.

steps

Create a minimal build definition where projects differ in their crossScalaVersions and applied Configurations:

sbt.version = 1.4.6
val scala212 = "2.12.12"
val scala213 = "2.13.4"

inThisBuild(
  List(
    organization := "org.example",
    scalaVersion := scala213,
    crossScalaVersions := List(scala212, scala213),
  )
)

// https://github.com/sbt/sbt/issues/3698#issuecomment-473530474
crossScalaVersions := Nil

lazy val core = project

lazy val app = project
  .dependsOn(core)
  .configs(IntegrationTest)
  .settings(Defaults.itSettings)
  .settings(
    scalaVersion := scala212,
    crossScalaVersions := List(scala212),
  )

Or a variation where scalaVersion doesn't differ, to distinguish from that aspect of #5586:

lazy val core = project
  .settings(crossScalaVersions += "2.11.12")

lazy val app = project
  .dependsOn(core)
  .configs(IntegrationTest)
  .settings(Defaults.itSettings)

problem

When running a task aggregated on root with +, which works as expected when crossScalaVersions is homogeneous, sbt appears to construct a task invocation for a configuration scope that is defined on one project but not others:

sbt:demo> +it:compile
[info] Setting Scala version to 2.12.12 on 2 projects.
[info] Excluded 1 projects, run ++ 2.12.12 -v for more details.
[info] Reapplying settings...
[info] set current project to demo (in build file:/private/tmp/demo/)
[success] Total time: 0 s, completed Jan 21, 2021 12:10:56 AM
[error] Expected ';'
[error] No such setting/task
[error] ++  2.13.4 core/It/compile

expectation

The aggregated +it:compile runs the task for the project where the Configuration is added, not projects where it is not.

@eed3si9n
Copy link
Member

Thanks for the report.

To supplement this, here's what happens without cross building as a reference.

ThisBuild / scalaVersion     := "2.13.4"
ThisBuild / version          := "0.1.0-SNAPSHOT"
ThisBuild / organization     := "com.example"

lazy val core = project

lazy val app = project
  .dependsOn(core)
  .configs(IntegrationTest)
  .settings(Defaults.itSettings)
sbt:hello> IntegrationTest/compile
[success] Total time: 0 s, completed Jan 23, 2021 2:32:59 PM
sbt:hello> core/IntegrationTest/compile
[error] No such setting/task
[error] core/IntegrationTest/compile
[error]

So the real aggregation feature of sbt is permissive of IntegrationTest not being present in core when called at the root level, but would error when specified as core/IntegrationTest/compile. So the emulated aggregation using + should follow that, and I agree with the expectation:

The aggregated +it:compile runs the task for the project where the Configuration is added, not projects where it is not.

@solarmosaic-kflorence
Copy link

Ran into this as well. Working around it for now with .configs(IntegrationTest).settings(IntegrationTest / test := {})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants