plugins {
    id 'java-gradle-plugin'
    id 'com.gradle.plugin-publish' version '0.21.0'
    id 'com.github.johnrengelman.shadow' version '7.1.2'

    id "pl.droidsonroids.jacoco.testkit" version "1.0.8"
    id 'jacoco'
}

group 'com.form.coverage'

gradlePlugin {
    plugins {
        diffCoveragePlugin {
            id = "com.form.diff-coverage"
            displayName = "Diff Coverage"
            description = "Plugin that computes code coverage on modified code"
            implementationClass = "com.form.coverage.gradle.DiffCoveragePlugin"
        }
    }
}
pluginBundle {
    website = 'https://github.com/form-com/diff-coverage-gradle'
    vcsUrl = 'https://github.com/form-com/diff-coverage-gradle.git'
    tags = ["coverage", "jacoco", "differential-coverage", "diff-coverage", "code-coverage"]
}

ext {
    junit_version = '5.7.2'
}

sourceSets {
    functionalTest {
        kotlin.srcDir file('src/funcTest/kotlin')
        resources.srcDir file('src/funcTest/resources')
        compileClasspath += sourceSets.main.output
        runtimeClasspath += sourceSets.main.output + compileClasspath
    }
}

configurations {
    functionalTestImplementation.extendsFrom testImplementation
    functionalTestRuntimeOnly.extendsFrom runtimeOnly
}

task functionalTest(type: Test) {
    description = 'Runs the functional tests.'
    group = 'verification'
    testClassesDirs = sourceSets.functionalTest.output.classesDirs
    classpath = sourceSets.functionalTest.runtimeClasspath
    useJUnitPlatform()
}
check.dependsOn functionalTest

gradlePlugin {
    testSourceSets sourceSets.functionalTest
}

jacocoTestKit {
    applyTo('functionalTestRuntimeOnly', tasks.named('functionalTest'))
}
functionalTest.dependsOn += generateJacocoFunctionalTestKitProperties

dependencies {
    implementation project(':jacoco-filtering-extension')

    testImplementation 'org.assertj:assertj-core:3.20.2'

    functionalTestImplementation 'org.eclipse.jgit:org.eclipse.jgit:5.12.0.202106070339-r'
    functionalTestImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
    functionalTestImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
    functionalTestRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"

}
