Search code examples
playframework-2.0sbtsbt-native-packager

Excluding unmanaged dependencies from universal:packageBin in sbt-native-packager?


I have an external lib directory with jars. I need these included in my classpath in order to compile and test my project but I do not want to include them in the distributed zip file that is generated via universal:packageBin (in the sbt-native-packager) (or dist if you're using the playframework.

I attempted to do this by using the provided scope as follows:

unmanagedBase in Provided := new java.io.File("/external/lib")

But this doesn't seem to work as advertised - the jars don't seem to get included in the Compile scope.

I am using sbt 0.13.1.


Solution

  • This works (thanks @jacek-laskowski for the improvements to my answer):

    mappings in Universal :=  (mappings in Universal).value.filter { case(jar, _) => jar.getParentFile != unmanagedBase.value }
    

    But, it still feels like a kludge, I would much prefer it if sbt (and the sbt-native-packager) would properly support the Provided scope as this scenario is exactly what it is meant for.