【发布时间】:2019-06-10 21:57:50
【问题描述】:
我正在尝试使用 Gatling 测试构建 jar 文件,最终我需要将其传递给 Taurus 但似乎我的 jar 太胖了,并且与 Taurus 的内部库发生冲突。
所以我认为我只需要打包我的测试文件而不需要其他依赖项。
我玩过sbt assembly,但它似乎将“太多”打包到 jar 文件中,我不知道如何限制它以避免像加特林本身这样的依赖关系。
我的一般项目结构类似于this repo。我在 repo 中没有 main 文件夹(我需要拥有它吗?)
sbt native packager 可以帮我吗?
更新
Here 是我用来测试组装的仓库
我想要包含的测试文件位于src/it
我的build.sbt(不确定在这种情况下是否都有意义)
enablePlugins(GatlingPlugin)
enablePlugins(AssemblyPlugin)
scalaVersion := "2.12.8"
// This forbids including Scala related libraries into the dependency
autoScalaLibrary := false
// dependencies for Gatling
libraryDependencies += "io.gatling.highcharts" % "gatling-charts-highcharts" % "3.0.2" % Provided
libraryDependencies += "io.gatling" % "gatling-test-framework" % "3.0.2" % Provided
assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)
// make '~' work (again :))
watchSources += baseDirectory.value / "src" / "it"
// configure the assembly
fullClasspath in assembly := (fullClasspath in GatlingIt).value
mainClass in assembly := Some("io.gatling.app.Gatling")
assemblyMergeStrategy in assembly := {
case path if path.endsWith("io.netty.versions.properties") => MergeStrategy.first
case path => {
val currentStrategy = (assemblyMergeStrategy in assembly).value
currentStrategy(path)
}
}
test in assembly := {}
我做sbt assembly 的结果是我仍然可以看到很多图书馆——包括加特林的图书馆。
【问题讨论】:
标签: scala sbt gatling sbt-assembly sbt-native-packager