/*
 * Copyright 2024 Aiven Oy
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
plugins {
    id 'java-library'
}

dependencies {
    implementation "org.apache.kafka:kafka-clients:$kafkaVersion"
    implementation project(":core")
    implementation project(":storage:s3")
    implementation project(":storage:gcs")
    implementation project(":storage:azure")
    implementation project(":storage:filesystem")
}

tasks.register('genConfigsDocs', JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    mainClass = 'io.aiven.kafka.tieredstorage.misc.ConfigsDocs'

    // Define the outputs formally
    outputs.file("$projectDir/configs.rst")

    // Set up the output in the execution phase, not configuration, and avoid removing on clean
    doFirst {
        standardOutput = new File("$projectDir/configs.rst").newOutputStream()
    }
}

tasks.register('genMetricsDocs', JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    mainClass = 'io.aiven.kafka.tieredstorage.misc.MetricsDocs'

    // Define the outputs formally
    outputs.file("$projectDir/metrics.rst")

    // Set up the output in the execution phase, not configuration, and avoid removing on clean
    doFirst {
        standardOutput = new File("$projectDir/metrics.rst").newOutputStream()
    }
}

tasks.named('compileJava') {
    finalizedBy 'genConfigsDocs', 'genMetricsDocs'
}