Open ktoso opened 10 years ago
This would be cool. Do you know what kind of work this would entail?
Yeah, there's two ways to do this, the awesome one:
jmh:assembly
produce the benchmarks.jar
The boring way:
I would love to do the first way of course, but I'm not sure how to "bring in another plugin I depend on". I have to read up on this. Help is very welcome if you would like to try!
How about we use the boring way for now--the awesome way seems easy enough to switch to later. I'll try it out for myself and report back.
Sounds good to me!
@mosesn @ktoso Any luck so far?
@martin-magakian sorry, I don't remember this ticket at all, too much time has passed.
@ktoso - Firstly, thank you for writing this plugin. Did you end up using the sbt-assembly plugin to create a jar? If so, can you share the steps.
If I did it would be documented and this ticket closed ;-) Pull requests welcome
@ktoso - I was able to get this working without much hassle. Included the sbt-assembly plugin -- addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
Then ran
jmh:compile
jmh:assembly
The jar can then be run using
java -cp /path/to/jar/assembly.jar org.openjdk.jmh.Main
Oh that’s awesome news that it just worked :-) I’ll give it a try later as well then :)
We can simply document it then I guess
On Thu, May 10, 2018 at 19:26, binarybrewery notifications@github.com wrote:
@ktoso https://github.com/ktoso - I was able to get this working without much hassle. Included the sbt-assembly plugin -- addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6") Then ran jmh:compile jmh:assembly The jar can then be run using java -cp /path/to/jar/assembly.jar org.openjdk.jmh.Main
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ktoso/sbt-jmh/issues/1#issuecomment-388124137, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHYk6aV_FmmIrjChXwuqhEpJW_pixtdks5txHhUgaJpZM4B8fMO .
-- Sent from Gmail Mobile
@ktoso - I was able to get this working without much hassle. Included the sbt-assembly plugin --
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
Then ranjmh:compile
jmh:assembly
The jar can then be run usingjava -cp /path/to/jar/assembly.jar org.openjdk.jmh.Main
This doesn't work for me.
When i run the jar i get Exception in thread "main" java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList
.
Can somebody explain the "boring" way, i.e. give instructions on how to use sbt-assembly?
I figured out how to build a fat jar using sbt-assembly.
This is how i configured my build.sbt
:
lazy val root = (project in file("."))
.enablePlugins(JmhPlugin)
.enablePlugins(JavaAppPackaging)
libraryDependencies ++= Seq(
"org.openjdk.jmh" % "jmh-core" % "1.22",
"org.openjdk.jmh" % "jmh-generator-annprocess" % "1.22"
)
assemblyJarName in assembly := "benchmarks.jar"
assemblyMergeStrategy in assembly := {
case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard
case _ => MergeStrategy.first
}
// rewire tasks, so that 'jmh:assembly' automatically invokes 'jmh:compile' (otherwise a clean 'jmh:assembly' would fail)
assembly in Jmh := (assembly in Jmh).dependsOn(Keys.compile in Jmh).value
I previously used case PathList("META-INF", xs @ _*) => MergeStrategy.discard
in my merge strategy which caused META-INF/BenchmarkList
to be discarded, hence, i always got ERROR: Unable to find the resource: /META-INF/BenchmarkList
. I fixed it by only discarding META-INF/MANIFEST.MF
.
And plugins.sbt
:
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.4")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
Now using sbt-assembly we can build a fat jar using jmh:assembly
and run the resulting jar as follows: java -cp /path/to/benchmarks.jar org.openjdk.jmh.Main
.
We need to be able to create a far "benchmarks.jar" like the maven version does