/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

plugins {
  id 'me.champeau.gradle.jmh'
  id 'nebula.facet'
}

configurations {
  javaagent {
    transitive = false
  }
}

dependencies {
  jmh(project(':geode-jmh'))

  javaagent(project(':geode-jmh'))
}

jmh {
  zip64 = true
  duplicateClassesStrategy = 'exclude'
  jvmArgs += ['-javaagent:' + configurations.javaagent.singleFile]

  include = project.hasProperty('jmh.include') ? project.property('jmh.include').tokenize() : ['.*']
  profilers = project.hasProperty('jmh.profilers') ? project.property('jmh.profilers').tokenize() : []
  threads = project.hasProperty('jmh.threads') ? project.property('jmh.threads') as Integer : null
  warmupIterations = project.hasProperty('jmh.warmupIterations') ? project.property('jmh.warmupIterations') as Integer : null
  iterations = project.hasProperty('jmh.iterations') ? project.property('jmh.iterations') as Integer : null
  timeOnIteration = project.hasProperty('jmh.timeOnIteration') ? project.property('jmh.timeOnIteration') as Integer : null
  fork = project.hasProperty('jmh.fork') ? project.property('jmh.fork') as Integer : null
  jvm = project.hasProperty('jmh.jvm') ? project.property('jmh.jvm') as String : null
  jvmArgs += project.hasProperty('jmh.jvmArgs') ? project.property('jmh.jvmArgs').tokenize() : []
}

jmhJar {
  exclude(['META-INF/*.SF'])
  exclude('META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat')
  exclude('*.jar')
}

facets {
  jmhTest {
    parentSourceSet = 'jmh'
    testTaskName = 'jmhTest'
    includeInCheckLifecycle = true
  }
}

jmhTest {
  useJUnitPlatform()
}

configurations {
  jmhTestRuntimeOnly.extendsFrom(jmhRuntimeOnly)
}

