SBT configuration vs Ivy module configuration

2019-05-18 01:09发布

This appears similar to sbt Configuration vs Ivy configuration, though it doesn't seem like this question is asked:

What is the difference between

libraryDependencies += "com.example" % "foo" % "1.0" % "test"

and

libraryDependencies in Test += "com.example" % "foo" % "1.0"

(And a similar question for IntegrationTest / "it".)

Should I always use SBT configuration, or Ivy configuration? Or does it depend on the particular case?

I have seen the former more often, though it seems that the latter is more consistent with the rest of my build.sbt.

1条回答
Summer. ? 凉城
2楼-- · 2019-05-18 01:51

update task and libraryDependencies are a bit odd ones because when you're downloading JARs you probably don't want to download Compile JARs and Test JARs independently or in parallel. For update task to handle all configurations, libraryDependencies needs to handle all configurations too.

libraryDependencies += "com.example" % "foo" % "1.0" % Test

means your project's Test configuration depends on the default configuration of "com.example" % "foo" % "1.0".

libraryDependencies in Test, I don't think would work.

Should I always use SBT configuration, or Ivy configuration? Or does it depend on the particular case?

There are notational differences, but conceptually sbt's configuration and Ivy configuration is the same thing.

查看更多
登录 后发表回答