apply from: "${rootProject.projectDir}/gradle/classpath-manifest.gradle"

ext {
    kindleGenCacheDir = "${offlineRepoBinariesRoot}/kindlegen"
}

dependencies {
    testRuntimeClasspath files(createClasspathManifest)

    cachedBinaries.add "kindlegen:${OS.macOsX ? 'KindleGen' : 'kindlegen'}" +
            ":${moduleVersions.kindlegen}" +
            ":${OS.linux ? 'linux_2.6_i386' : (OS.windows ? 'win32' : 'Mac_i386')}" +
            "@${OS.linux ? 'tar.gz' : 'zip'}"
}

test {
    systemProperties 'org.asciidoctor.gradle.kindlegen.uri' : file(kindleGenCacheDir).absoluteFile.toURI()

    dependsOn createClasspathManifest
    dependsOn ':testfixtures-offline-repo:buildOfflineRepositories'
    systemProperties OFFLINE_REPO: offlineRepoRoot.absolutePath
}

pluginManager.withPlugin('jacoco') {
    jacocoTestReport {
        executionData.setFrom(fileTree('.') { exclude '**' })
        executionData test
    }
}

configurePlugin 'org.asciidoctor.kindlegen.base',
    'Kindlegen Gradle Base Plugin',
    'Provides kindlegen extension and removes need to install kindlegen manually',
    [ 'kindlegen', 'epub', 'epub3', 'kf8']

