plugins {
    id 'org.springframework.boot' version '2.6.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'org.asciidoctor.jvm.convert' version '3.3.2'
    id 'java'
}

group = 'com.example'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = 8

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

repositories {
    mavenCentral()
}

ext {
    set('snippetsDir', file("build/generated-snippets"))
}

test {
    outputs.dir snippetsDir
    useJUnitPlatform()
}

asciidoctor {
    inputs.dir snippetsDir
    setOptions([
            'doctype': 'book',
            'backend': 'html5'
    ])
    setAttributes([
            'snippets'          : snippetsDir,
            'source-highlighter': 'coderay',
            'toc'               : 'left',
            'toclevels'         : '3',
            'sectlinks'         : 'true'
    ])
    dependsOn test
}

bootJar {
    dependsOn test, asciidoctor
    from("${asciidoctor.outputDir}/html5") {
        into 'BOOT-INF/classes/static/docs'
    }
}

dependencies {
    implementation('org.springframework.boot:spring-boot-starter-actuator')
    implementation('org.springframework.boot:spring-boot-starter-data-mongodb-reactive')
    implementation('org.springframework.boot:spring-boot-starter-webflux')
    implementation('org.springframework.boot:spring-boot-starter-validation')
    implementation('org.springframework.boot:spring-boot-starter-security')
    implementation('org.apache.commons:commons-lang3')
    implementation('org.modelmapper:modelmapper:2.3.5')
    developmentOnly('org.springframework.boot:spring-boot-devtools')
    runtimeOnly('de.flapdoodle.embed:de.flapdoodle.embed.mongo')
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation('org.springframework.security:spring-security-test')
    testImplementation('io.projectreactor:reactor-test')
    testImplementation('org.springframework.restdocs:spring-restdocs-asciidoctor')
    testImplementation('org.springframework.restdocs:spring-restdocs-webtestclient')
    testImplementation('org.mockito:mockito-junit-jupiter')
    testImplementation('org.junit.jupiter:junit-jupiter-params')
}
