dependencies {
    testImplementation project( ':core:core-content' )
    testImplementation project( ':core:core-audit' )
    testImplementation project( ':core:core-repo' )
    testImplementation project( ':core:core-schema' )
    testImplementation project( ':core:core-event' )
    testImplementation project( ':core:core-media' )
    testImplementation project( ':core:core-site' )
    testImplementation project( ':core:core-project' )
    testImplementation project( ':core:core-scheduler' )
    testImplementation project( ':core:core-app' )
    testImplementation project( ':core:core-export' )

    testImplementation libs.hazelcast.hazelcast

    testImplementation( testFixtures( project( ":core:core-api" ) ) )
    testImplementation( testFixtures( project( ":core:core-blobstore" ) ) )
    testImplementation( testFixtures( project( ":core:core-security" ) ) )
    testImplementation( testFixtures( project( ":core:core-task" ) ) )
    testImplementation( testFixtures( project( ":core:core-internal" ) ) )
    testImplementation( testFixtures( project( ":core:core-app" ) ) )

    testImplementation libs.felix.framework

    testFixturesApi project( ':core:core-api' )
    testFixturesImplementation( project( ":core:core-audit" ) )
    testFixturesImplementation( project( ":core:core-scheduler" ) )
    testFixturesImplementation( project( ":core:core-app" ) )
    testFixturesImplementation( project( ":core:core-security" ) )
    testFixturesImplementation( testFixtures( project( ":core:core-blobstore" ) ) )
    testFixturesImplementation libs.junit.jupiter.api
    testFixturesImplementation libs.mockito.core
    testFixturesApi( libs.elasticsearch ) {
        exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-cbor'
        exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-yaml'
        exclude group: 'org.yaml', module: 'snakeyaml'
        exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-smile'
    }
}

def integration = gradle.sharedServices.registerIfAbsent( "integration", BuildService ) {
    maxParallelUsages = 1
}

tasks.register( 'integrationTest', Test ) {
    usesService( integration )
    description = 'Runs integration tests.'
    group = 'verification'

    useJUnitPlatform {
        includeTags 'elasticsearch'
    }

    testClassesDirs = sourceSets.test.output.classesDirs
    classpath = sourceSets.test.runtimeClasspath

    systemProperty 'java.awt.headless', 'true'
    maxHeapSize = '2G'

    shouldRunAfter test
}

check.dependsOn( tasks.named( 'integrationTest' ) )

tasks.named( 'jacocoTestReport' ) {
    dependsOn( tasks.named( 'integrationTest' ) )
    executionData.from = fileTree( layout.buildDirectory ).include( "/jacoco/*.exec" )
}
