2017-08-12 78 views
0

我正在使用gatling工具進行性能測試。我的gatling代碼運行完美。我正在爲我的項目使用intellij IDEA。我正在嘗試創建一個jar文件。它不能創建。我認爲這是SBT problem.please有人糾正我的SB我build.sbt文件是在這裏:加特林sbt組裝jar文件不能創建?

import io.gatling.sbt.GatlingPlugin 
import sbtassembly.MergeStrategy 

parallelExecution in Test := false 
enablePlugins(GatlingPlugin, AssemblyPlugin) 
lazy val root = (project in file(".")) 
.configs(IntegrationTest) 
.settings(Defaults.itSettings: _*) 

Project.inConfig(IntegrationTest)(baseAssemblySettings) 
mainClass in assembly := Some("gatling.GatlingMain") 
assemblyMergeStrategy in assembly := { 
case x => 
val oldStrategy = (assemblyMergeStrategy in assembly).value 
oldStrategy(x) 
} 
libraryDependencies ++= Seq(
"com.typesafe.play" % "play-json_2.11" % "2.6.2" % IntegrationTest, 
"org.scalacheck" % "scalacheck_2.11" % "1.13.5" % IntegrationTest, 
"com.typesafe" % "config" % "1.3.1" % IntegrationTest, 
"io.gatling.highcharts" % "gatling-charts-highcharts" % "2.2.5" % 
IntegrationTest, 
"io.gatling" % "gatling-test-framework" % "2.2.5" % IntegrationTest, 
"com.google.code.gson" % "gson" % "2.8.0" % IntegrationTest 
) 
resourceDirectory in Compile := baseDirectory.value /"resources" 
assemblyJarName in (IntegrationTest, assembly):=s"${name.value}-${version.value}.jar" 

當我嘗試使用創建一個jar文件SBT命令SBT「吧:集結號」 它顯示了以下錯誤

[error] 1 error was encountered during merge 
    java.lang.RuntimeException: deduplicate: different file contents found in the following: 
    /Users/james/.ivy2/cache/io.netty/netty-buffer/jars/netty-buffer-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
    /Users/james/.ivy2/cache/io.netty/netty-common/jars/netty-common-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
    /Users/james/.ivy2/cache/io.netty/netty-codec-http/jars/netty-codec-http-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
/Users/james/.ivy2/cache/io.netty/netty-codec/jars/netty-codec-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
/Users/james/.ivy2/cache/io.netty/netty-transport/jars/netty-transport-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
/Users/james/.ivy2/cache/io.netty/netty-handler/jars/netty-handler-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
/Users/james/.ivy2/cache/io.netty/netty-transport-native-epoll/jars/netty-transport-native-epoll-4.0.44.Final-linux-x86_64.jar:META-INF/io.netty.versions.properties 
    at sbtassembly.Assembly$.applyStrategies(Assembly.scala:140) 
    at sbtassembly.Assembly$.x$1$lzycompute$1(Assembly.scala:25) 
    at sbtassembly.Assembly$.x$1$1(Assembly.scala:23) 
    at sbtassembly.Assembly$.stratMapping$lzycompute$1(Assembly.scala:23) 
    at sbtassembly.Assembly$.stratMapping$1(Assembly.scala:23) 
    at sbtassembly.Assembly$.inputs$lzycompute$1(Assembly.scala:67) 
    at sbtassembly.Assembly$.inputs$1(Assembly.scala:57) 
    at sbtassembly.Assembly$.apply(Assembly.scala:83) 
    at sbtassembly.Assembly$$anonfun$assemblyTask$1.apply(Assembly.scala:245) 
    at sbtassembly.Assembly$$anonfun$assemblyTask$1.apply(Assembly.scala:242) 
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) 
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40) 
    at sbt.std.Transform$$anon$4.work(System.scala:63) 
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228) 
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228) 
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17) 
    at sbt.Execute.work(Execute.scala:237) 
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228) 
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228) 
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159) 
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
    [error] (it:assembly) deduplicate: different file contents found in the following: 
    [error] /Users/james/.ivy2/cache/io.netty/netty-buffer/jars/netty-buffer-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
    [error] /Users/james/.ivy2/cache/io.netty/netty-common/jars/netty-common-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
    [error] /Users/james/.ivy2/cache/io.netty/netty-codec-http/jars/netty-codec-http-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
    [error] /Users/james/.ivy2/cache/io.netty/netty-codec/jars/netty-codec-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
    [error] /Users/james/.ivy2/cache/io.netty/netty-transport/jars/netty-transport-4.0.44.Final.jar:META-INF/io.netty.versions.properties 
    [error] /Users/james/.ivy2/cache/io.netty/netty-handler/jars/netty-handler-4.0.44.Final.jar:META-INF/io.netty.versions.properties 

我的sbt版本是0.13.16,我的scala版本是2.11.8。請有人幫我解決這個錯誤。在此先感謝

回答

0

很可能你不需要所有io.netty庫中的io.netty.versions.properties,可能就足夠了。我認爲這樣的事情應該可以工作:

assemblyMergeStrategy in assembly := { 
case p if p.endsWith("io.netty.versions.properties") => 
    MergeStrategy.first 
case x => 
    val oldStrategy = (assemblyMergeStrategy in assembly).value 
    oldStrategy(x) 
}