From 83aeb8976d90ad1637243953a9af37e6d4206c52 Mon Sep 17 00:00:00 2001 From: Nikolay Tatarinov <5min4eq.unity@gmail.com> Date: Wed, 28 Mar 2018 01:33:11 +0300 Subject: WIP: Play json build (#182) * play json build * build progress * add check task * try to make play json js build * scalariform and mima plugins in separate files. check mima * better error message for mima compatibility check * fix scala 2.10 compilation * license headers support * add jmh support * fix reformat on compile; fix code validation; extract base module * remove scala 2.13 from cross versions * include play-json in integration tests * add example .travis.yml * bring back scala 2.13 support * make reformat target, not command * add release task * update mill version in travis.yml * update release script * update release process * add README.md for play json build --- integration/test/resources/play-json/jmh.sc | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 integration/test/resources/play-json/jmh.sc (limited to 'integration/test/resources/play-json/jmh.sc') diff --git a/integration/test/resources/play-json/jmh.sc b/integration/test/resources/play-json/jmh.sc new file mode 100644 index 00000000..76ed43fc --- /dev/null +++ b/integration/test/resources/play-json/jmh.sc @@ -0,0 +1,61 @@ +import ammonite.ops._ +import mill._, scalalib._, modules._ + +trait Jmh extends ScalaModule { + + def ivyDeps = super.ivyDeps() ++ Agg(ivy"org.openjdk.jmh:jmh-core:1.19") + + def runJmh(args: String*) = T.command { + val (_, resources) = generateBenchmarkSources() + Jvm.interactiveSubprocess( + "org.openjdk.jmh.Main", + classPath = (runClasspath() ++ generatorDeps()).map(_.path) ++ + Seq(compileGeneratedSources().path, resources), + mainArgs = args, + workingDir = T.ctx.dest + ) + } + + def compileGeneratedSources = T { + val dest = T.ctx.dest + val (sourcesDir, _) = generateBenchmarkSources() + val sources = ls.rec(sourcesDir).filter(_.isFile) + %%("javac", + sources.map(_.toString), + "-cp", + (runClasspath() ++ generatorDeps()).map(_.path.toString).mkString(":"), + "-d", + dest)(wd = dest) + PathRef(dest) + } + + // returns sources and resources directories + def generateBenchmarkSources = T { + val dest = T.ctx().dest + + val sourcesDir = dest / 'jmh_sources + val resourcesDir = dest / 'jmh_resources + + rm(sourcesDir) + mkdir(sourcesDir) + rm(resourcesDir) + mkdir(resourcesDir) + + Jvm.subprocess( + "org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator", + (runClasspath() ++ generatorDeps()).map(_.path), + mainArgs = Array( + compile().classes.path, + sourcesDir, + resourcesDir, + "default" + ).map(_.toString) + ) + + (sourcesDir, resourcesDir) + } + + def generatorDeps = resolveDeps( + T { Agg(ivy"org.openjdk.jmh:jmh-generator-bytecode:1.19") } + ) +} -- cgit v1.2.3