buildscript {
    repositories {
        mavenCentral()
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }
    dependencies {
        classpath 'com.github.davidmc24.gradle.plugin:gradle-avro-plugin:1.0.0'
    }
}

plugins {
    id 'java'
    id 'groovy'
    // does not work with Java 10
    // id 'jacoco'
    alias(libs.plugins.jmh)
}

apply plugin: 'com.github.davidmc24.gradle.plugin.avro'
apply plugin: 'idea'

configurations {
    jmh
}

jmh {
    includes = ['tech\\.allegro\\.schema\\.json2avro\\.converter\\..*']
    humanOutputFile = null
    jmhVersion = '1.20'
    iterations = 2
    timeOnIteration = '10s'
    fork = 1
    warmupIterations = 1
    warmup = '10s'
    failOnError = true
    threads = 1
    duplicateClassesStrategy = DuplicatesStrategy.WARN
}

dependencies {
    implementation libs.avro

    testImplementation libs.spock
    testImplementation libs.groovy
}

idea {
    module {
        scopes.PROVIDED.plus += [ configurations.jmh ]
    }
}

// Workaround for duplicated `BenchmarkList` and `CompilerHints` files from META-INF directory in jmh jar.
// Those duplications can prevent from running benchmark tests.
// More info https://github.com/melix/jmh-gradle-plugin/issues/6
tasks.getByName('jmhJar').doFirst() {duplicatesStrategy(DuplicatesStrategy.EXCLUDE)}