
sourceSets {
    intTest
}

configurations {
    intTestOfflineRepo {
        canBeConsumed = false
        canBeResolved = true
    }
}

// For a single test, you can run "gradle intTest --tests <test name> "
tasks.register('intTest', Test) {
    description = "Runs the plugin's integration tests"
    group = "verification"

    mustRunAfter "test"
    inputs.files sourceSets.main.output.classesDirs
    inputs.files sourceSets.main.output.resourcesDir

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

    dependsOn ':testfixtures-offline-repo:buildOfflineRepositories'
    systemProperties OFFLINE_REPO: offlineRepoRoot.absolutePath,
            TEST_PROJECTS_DIR: file('src/intTest/projects')
}

tasks.named('check') {
    dependsOn 'intTest'
}

pluginManager.withPlugin('jacoco') {
    jacocoTestReport {
        executionData tasks.intTest
        mustRunAfter 'intTest'
    }
}

pluginManager.withPlugin('java-gradle-plugin') {
    gradlePlugin {
        testSourceSets sourceSets.intTest
    }
}