I have the following project structure:
/
├── project
| └── ...
├── src
| └── ...
├── lib
│ ├── prod-lib.jar
| └── test-lib.jar
└── build.sbt
And I need to compile with test-lib.jar
for deploying into a testing environment and with prod-lib.jar
for deploying into a production environment.
Both of them have the same API for accessing the things I need, so my source code does not have any problem with neither of them, but both have subtle differences on how they implement their execution in the background.
Is there a way to create a "sbt task" (Or maybe anything else) that can ignore one jar or the other, but in both perform the assembly
task anyway?
Put your jars in different folders and set unmanagedBase
key in Compile
and Test
scopes correspondingly:
> set unmanagedBase in Compile := baseDirectory.value / "lib-compile"
> show compile:assembly::unmanagedBase
[info] /project/foo/lib-compile
> set unmanagedBase in Test := baseDirectory.value / "lib-test"
> show test:assembly::unmanagedBase
[info] /project/foo/lib-test
But don't forget to call assembly
task in the corresponding scope then (compile:assembly
or test:assembly
), because in Global
it's still the default:
> show assembly::unmanagedBase
[info] /project/foo/lib