阻止SBT在构建中包含插件jar

时间:2014-06-04 06:02:36

标签: scala sbt

如何告诉SBT在我的项目构建中不包含SBT插件的JAR? 我注意到插件JAR,比如graphSettings,sbt-git和喜欢的东西都打包在我的最终版本中。

此外,即使我将特定依赖项设置为"提供",它仍然会在构建中打包。

提前谢谢大家。

我的Build.scala文件:

object DALBuild extends Build {

  sbtPlugin := true

  val akkaVersion = "2.2.3"
  val sprayVersion = "1.2.1"
  val scalatraVersion = "2.2.2"

  lazy val dal = Project(

    id = "dal",
    base = file("."),
    settings = Project.defaultSettings ++ SbtOneJar.oneJarSettings ++ Seq(

      name := "DAL",
      organization := "com.foo.bar",
      version := "0.5.28-SNAPSHOT",
      scalaVersion := "2.10.4",
      scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature"),
      mainClass in SbtOneJar.oneJar := Some("com.foo.bar.http.server.BootDAL"),
      retrieveManaged := true,
      parallelExecution in Test := false,
      fork in run := false,
      fork in Test := true,
      javaOptions in run += "-Dlogback.configurationFile=logback-dev.xml",
      javaOptions in Test += "-Dlogback.configurationFile=logback-test.xml",
      javaOptions in run += "-DUssdDb.env=dev",

      resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases",
      resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/",
      resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/",
      resolvers += "spray repo" at "http://repo.spray.io",

      libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % akkaVersion,
      libraryDependencies += "com.typesafe.slick" % "slick_2.10" % "1.0.0",
      libraryDependencies += "net.sourceforge.jtds" % "jtds" % "1.2.4",
      libraryDependencies += "org.apache.cxf" % "cxf-rt-frontend-jaxws" % "2.7.5" exclude("commons-logging", "commons-logging"),
      libraryDependencies += "org.apache.cxf" % "cxf-rt-transports-http-hc" % "2.7.5" exclude("commons-logging", "commons-logging"),
      libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.0.13",
      libraryDependencies += "org.apache.tomcat" % "tomcat-jdbc" % "7.0.30",
      libraryDependencies += "net.sourceforge.expectj" % "expectj" % "2.0.1" exclude("commons-logging", "commons-logging"),
      libraryDependencies += "commons-net" % "commons-net" % "3.2",
      libraryDependencies += "commons-beanutils" % "commons-beanutils" % "1.9.1" exclude("commons-logging", "commons-logging"),
      libraryDependencies += "commons-logging" % "commons-logging" % "1.1.1" % "provided",
      libraryDependencies += "org.slf4j" % "jcl-over-slf4j" % "1.7.7",
      libraryDependencies += "org.scalatra" %% "scalatra" % scalatraVersion,
      libraryDependencies += "org.scalatra" %% "scalatra-swagger"  % scalatraVersion exclude("org.slf4j", "slf4j-log4j12"),
      libraryDependencies += "org.scalatra" %% "scalatra-scalate" % scalatraVersion,
      libraryDependencies += "org.scalatra" %% "scalatra-json" % scalatraVersion,
      libraryDependencies += "org.eclipse.jetty" % "jetty-webapp" % "9.0.2.v20130417",
      libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.2.4",
      libraryDependencies += "org.json4s"   %% "json4s-native" % "3.2.4",
      libraryDependencies += "io.spray" % "spray-client" % sprayVersion,

      libraryDependencies += "org.scalatest" % "scalatest_2.10" % "1.9.1" % "test",
      libraryDependencies += "org.scalatra" %% "scalatra-scalatest" % scalatraVersion % "test",
      libraryDependencies += "com.typesafe.akka" % "akka-testkit_2.10" % akkaVersion % "test",

      testOptions += Setup(cl => cl.loadClass("org.slf4j.LoggerFactory").
        getMethod("getLogger",cl.loadClass("java.lang.String")).
        invoke(null,"ROOT"))
    )

  )
    .settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*)
}

1 个答案:

答案 0 :(得分:2)

看起来像SbtOneJar的问题 - 您可能想直接向他们提出问题。

您可以更改设置 - 例如:mappings in oneJar [1]尽管您的milage可能会有所不同。或者,查找支持provided [2]的库。

[1] https://github.com/sbt/sbt-onejar/blob/master/src/main/scala/com/github/retronym/SbtOneJar.scala#L37

[2] https://github.com/sbt/sbt-assembly#-provided-configuration