build.gradle 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import org.elasticsearch.gradle.info.BuildParams
  2. /*
  3. * Licensed to Elasticsearch under one or more contributor
  4. * license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright
  6. * ownership. Elasticsearch licenses this file to you under
  7. * the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. apply plugin: 'elasticsearch.build'
  21. apply plugin: 'application'
  22. mainClassName = 'org.openjdk.jmh.Main'
  23. assemble.enabled = false
  24. archivesBaseName = 'elasticsearch-benchmarks'
  25. test.enabled = false
  26. dependencies {
  27. api( project(":server")) {
  28. // JMH ships with the conflicting version 4.6. This prevents us from using jopt-simple in benchmarks (which should be ok) but allows
  29. // us to invoke the JMH uberjar as usual.
  30. exclude group: 'net.sf.jopt-simple', module: 'jopt-simple'
  31. }
  32. api "org.openjdk.jmh:jmh-core:$versions.jmh"
  33. annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:$versions.jmh"
  34. // Dependencies of JMH
  35. runtimeOnly 'net.sf.jopt-simple:jopt-simple:4.6'
  36. runtimeOnly 'org.apache.commons:commons-math3:3.2'
  37. }
  38. // enable the JMH's BenchmarkProcessor to generate the final benchmark classes
  39. // needs to be added separately otherwise Gradle will quote it and javac will fail
  40. compileJava.options.compilerArgs.addAll(["-processor", "org.openjdk.jmh.generators.BenchmarkProcessor"])
  41. run.executable = "${BuildParams.runtimeJavaHome}/bin/java"
  42. // classes generated by JMH can use all sorts of forbidden APIs but we have no influence at all and cannot exclude these classes
  43. disableTasks('forbiddenApisMain')
  44. // No licenses for our benchmark deps (we don't ship benchmarks)
  45. tasks.named("dependencyLicenses").configure { it.enabled = false }
  46. dependenciesInfo.enabled = false
  47. thirdPartyAudit.ignoreViolations(
  48. // these classes intentionally use JDK internal API (and this is ok since the project is maintained by Oracle employees)
  49. 'org.openjdk.jmh.profile.AbstractHotspotProfiler',
  50. 'org.openjdk.jmh.profile.HotspotThreadProfiler',
  51. 'org.openjdk.jmh.profile.HotspotClassloadingProfiler',
  52. 'org.openjdk.jmh.profile.HotspotCompilationProfiler',
  53. 'org.openjdk.jmh.profile.HotspotMemoryProfiler',
  54. 'org.openjdk.jmh.profile.HotspotRuntimeProfiler',
  55. 'org.openjdk.jmh.util.Utils'
  56. )
  57. spotless {
  58. java {
  59. // IDEs can sometimes run annotation processors that leave files in
  60. // here, causing Spotless to complain. Even though this path ought not
  61. // to exist, exclude it anyway in order to avoid spurious failures.
  62. targetExclude 'src/main/generated/**/*.java'
  63. }
  64. }