Exclude libraries that are marked as Provided using the sbt-osgi plugin
使用 sbt-osgi 插件,可以通过使用
例如,以下代码(从该测试中提取)将名称以
1 2 | OsgiKeys.embeddedJars := (Keys.externalDependencyClasspath in Compile).value map (_.data) filter ( _.getName startsWith"junit") |
就我而言,我的依赖项声明如下:
1 2 | libraryDependencies +="org.apache.logging.log4j" %"log4j-api" %"2.7" % Provided libraryDependencies +="com.typesafe.akka" %%"akka-actor" % akkaVersion |
我希望每个库都嵌入到胖罐中,除了那些用
有没有什么办法可以修改上面的过滤方法,使其满足我的要求?
我找到了一种方法来实现我想要的:
1 2 3 4 5 6 7 8 9 10 11 12 13 | OsgiKeys.embeddedJars := (Keys.externalDependencyClasspath in Compile).value.map(_.data).filter( file => { /* * Find configs for file and return false if it includes"test" or"provided" */ libraryDependencies.value.map(x => { (x.name.toLowerCase, x.configurations.map(_.toLowerCase)) }) .find { case (n, _) => file.getName.toLowerCase.contains(n) } .flatMap {case (_, c) => c} match { case x if x.contains("test") => false case x if x.contains("provided") => false case _ => true } }) |