buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "me.champeau.jmh:jmh-gradle-plugin:${gradleJmhPluginVersion}"
    }
}

apply plugin: "me.champeau.jmh"

dependencies {
    api project(':doov-sample-generated')
    api project(':doov-sample-example')
    api group: 'io.doov', name: 'doov-assertions'
    implementation group: 'org.openjdk.jmh', name: 'jmh-core'
    implementation group: 'org.openjdk.jmh', name: 'jmh-generator-annprocess'
    implementation (group: 'org.jfree', name: 'jfreechart') {
        exclude group: 'javax.servlet', module: 'servlet-api'
        exclude group: 'junit', module: 'junit'
    }
    api group: 'org.hibernate.validator', name: 'hibernate-validator'
    api group: 'org.hibernate.validator', name: 'hibernate-validator-cdi'
    api group: 'org.glassfish', name: 'jakarta.el'
}

task copyEmptyBmList(type: Copy) {
    from "$buildDir/jmh-generated-classes/META-INF/BenchmarkList"
    into "$buildDir/tmp"
}
jmhRunBytecodeGenerator.finalizedBy copyEmptyBmList

task copyEmptyBmListBack(type: Copy) {
    from "$buildDir/tmp/BenchmarkList"
    into "$buildDir/jmh-generated-classes/META-INF"
}
jmhCompileGeneratedClasses.finalizedBy copyEmptyBmListBack

sourceSets {
    jmh {
        java.srcDirs "${projectDir}/src/main/java"
    }
}


jmh {
    duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
}

build.dependsOn jmhJar