sourceSets {
    integrationTest {
        java {
            srcDirs += []
        }
        kotlin {
            srcDirs += ['src/integrationTest/kotlin', 'src/integrationTest/java']
        }
        resources.srcDir file('src/integrationTest/resources')
        compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
        runtimeClasspath += output + compileClasspath
    }
}

configurations {
    integrationTestImplementation.extendsFrom testImplementation
    integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}

task integrationTest(type: Test) {
    description = 'Runs the integration tests.'
    group = 'verification'
    testClassesDirs = sourceSets.integrationTest.output.classesDirs
    classpath = sourceSets.integrationTest.runtimeClasspath
    mustRunAfter test
    testLogging {
        events "passed", "skipped", "failed", "standardOut", "standardError"
    }
    systemProperty('gradle.args', 'buildEnv dependencies assemble -S')
    systemProperty 'android.minsdk.version', 18
}

check.dependsOn integrationTest

compileIntegrationTestKotlin {
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
        apiVersion = "1.5"
        freeCompilerArgs = ["-Xno-optimized-callable-references"]
    }
}

tasks.withType(ProcessResources).configureEach {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
