mirror of https://github.com/sbt/sbt.git
Set bgCopyClasspath false for shared layer config
It isn't possible to share the runtime and test layers correctly with bgCopyClasspath is used because the runtime classpath uses the dependencies copied to the boot directory while the test classpath uses the classes in target and .ivy2. Since this is not the default and users have to opt in to ClassLoaderLayeringStrategy.ShareRuntimeDependenciesLayerWithTestDependencies, I think this is fine.
This commit is contained in:
parent
a4f1d23d71
commit
399dd920b0
|
|
@ -112,7 +112,9 @@ object ClassLoaderLayeringStrategy {
|
|||
* Add the TestDependencies layer on top of the RuntimeDependencies layer on top of the
|
||||
* ScalaInstance layer. This differs from TestDependencies in that it will not reload the
|
||||
* runtime classpath. The drawback to using this is that if the test dependencies evict
|
||||
* classes provided in the runtime layer, then tests can fail.
|
||||
* classes provided in the runtime layer, then tests can fail. In order for sharing the runtime
|
||||
* layer to work, it is necessary to set [[Keys.bgCopyClasspath]] to false. Otherwise the
|
||||
* runtime and test classpaths are completely different.
|
||||
*/
|
||||
case object ShareRuntimeDependenciesLayerWithTestDependencies
|
||||
extends ScalaInstance
|
||||
|
|
|
|||
|
|
@ -1781,7 +1781,15 @@ object Defaults extends BuildCommon {
|
|||
// by the test task layers may be cached without evicting the runtime classloader layers. The
|
||||
// cache size should be a multiple of two to support snapshot layers.
|
||||
ClassLoaderCache(4)
|
||||
)
|
||||
),
|
||||
bgCopyClasspath in bgRun := {
|
||||
val old = (bgCopyClasspath in bgRun).value
|
||||
old && (Test / classLoaderLayeringStrategy).value != ClassLoaderLayeringStrategy.ShareRuntimeDependenciesLayerWithTestDependencies
|
||||
},
|
||||
bgCopyClasspath in bgRunMain := {
|
||||
val old = (bgCopyClasspath in bgRunMain).value
|
||||
old && (Test / classLoaderLayeringStrategy).value != ClassLoaderLayeringStrategy.ShareRuntimeDependenciesLayerWithTestDependencies
|
||||
},
|
||||
)
|
||||
|
||||
lazy val testSettings: Seq[Setting[_]] = configSettings ++ testTasks ++
|
||||
|
|
|
|||
Loading…
Reference in New Issue