build.gradle 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import org.elasticsearch.gradle.internal.info.BuildParams
  2. /*
  3. * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
  4. * or more contributor license agreements. Licensed under the Elastic License
  5. * 2.0 and the Server Side Public License, v 1; you may not use this file except
  6. * in compliance with, at your election, the Elastic License 2.0 or the Server
  7. * Side Public License, v 1.
  8. */
  9. apply plugin: 'elasticsearch.java'
  10. apply plugin: 'application'
  11. mainClassName = 'org.openjdk.jmh.Main'
  12. tasks.named("assemble").configure { enabled = false }
  13. archivesBaseName = 'elasticsearch-benchmarks'
  14. tasks.named("test").configure { enabled = false }
  15. configurations {
  16. expression
  17. painless
  18. }
  19. dependencies {
  20. api(project(":server")) {
  21. // JMH ships with the conflicting version 4.6. This prevents us from using jopt-simple in benchmarks (which should be ok) but allows
  22. // us to invoke the JMH uberjar as usual.
  23. exclude group: 'net.sf.jopt-simple', module: 'jopt-simple'
  24. }
  25. expression(project(path: ':modules:lang-expression', configuration: 'zip'))
  26. painless(project(path: ':modules:lang-painless', configuration: 'zip'))
  27. api "org.openjdk.jmh:jmh-core:$versions.jmh"
  28. annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:$versions.jmh"
  29. // Dependencies of JMH
  30. runtimeOnly 'net.sf.jopt-simple:jopt-simple:4.6'
  31. runtimeOnly 'org.apache.commons:commons-math3:3.2'
  32. }
  33. // enable the JMH's BenchmarkProcessor to generate the final benchmark classes
  34. // needs to be added separately otherwise Gradle will quote it and javac will fail
  35. tasks.named("compileJava").configure {
  36. options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])
  37. }
  38. tasks.register('copyExpression', Copy) {
  39. dependsOn configurations.expression
  40. from { configurations.expression.collect { zipTree(it) } }
  41. into "${buildDir}/plugins/expression"
  42. }
  43. tasks.register("copyPainless", Copy) {
  44. dependsOn configurations.painless
  45. from { configurations.painless.collect { zipTree(it) } }
  46. into "${buildDir}/plugins/painless"
  47. }
  48. tasks.named("run").configure {
  49. executable = "${BuildParams.runtimeJavaHome}/bin/java"
  50. jvmArgs << "-Dplugins.dir=${buildDir}/plugins" << "-Dtests.index=${buildDir}/index"
  51. dependsOn "copyExpression", "copyPainless"
  52. }
  53. spotless {
  54. java {
  55. // IDEs can sometimes run annotation processors that leave files in
  56. // here, causing Spotless to complain. Even though this path ought not
  57. // to exist, exclude it anyway in order to avoid spurious failures.
  58. targetExclude 'src/main/generated/**/*.java'
  59. }
  60. }