Search code examples
scalabuildsbtintegration-testingbare

SBT: Add/enable IntegrationTest configuration in bare build.sbt


I have a build.sbt written in bare style, i.e. containing only SettingKeys. I want to add IntegrationTest configuration to project, but I can't manage to do so without declaring a project and calling configs method on it like following:

lazy val root = (project in file(".")).configs(IntegrationTest).settings(
  build.projectSettings,
  Defaults.itSettings
)

Simply adding Defaults.itSettings to build.sbt results in exception about nonexistent configuration

java.lang.IllegalArgumentException: Cannot add dependency 'org.cassandraunit#cassandra-unit;3.3.0.2' to configuration 'it' of module com-mymodule because this configuration doesn't exist!

How can I both keep my build.sbt in bare style and add IntegrationTest config?


Solution

  • You can add configs to the build.sbt directly:

    configs(IntegrationTest)
    Defaults.itSettings
    

    You should understand though that if you have a multi-project build, it's better to declare all projects and their common settings explicitly.