import java.text.SimpleDateFormat

apply plugin: "com.diffplug.gradle.spotless"
apply plugin: "org.asciidoctor.convert"
apply plugin: "org.ajoberstar.git-publish"
apply plugin: "jacoco"

ext {
    snippetsDir = file("build/generated-snippets")
}

sourceCompatibility = 11

repositories {
    mavenCentral()
}

spotless {
    java {
        googleJavaFormat()
    }
}

dependencies {
    compile project(":coderadar-plugins:loc-analyzer-plugin")
    compile project(":coderadar-plugins:checkstyle-analyzer-plugin")
    compile project(":coderadar-graph")
    compile project(":coderadar-dependency-map")
    compile project(":coderadar-core")
    compile project(":coderadar-vcs")
    compile project(":coderadar-rest")

    testCompile "org.springframework.boot:spring-boot-starter-test:${version_spring_boot}"
    testCompile "org.springframework.restdocs:spring-restdocs-mockmvc:${version_spring_restdocs}"
    testCompile "org.springframework.restdocs:spring-restdocs-core:${version_spring_restdocs}"
    testCompile group: 'net.lingala.zip4j', name: 'zip4j', version: '2.2.4'


    testCompile ('org.neo4j.test:neo4j-harness:3.2.9') {
        exclude group: 'org.eclipse.jetty', module: 'jetty-webapp'
    }
    testCompile 'org.neo4j:neo4j-ogm-embedded-driver:3.2.9'
    testCompile group: 'org.neo4j.procedure', name: 'apoc', version: "3.5.0.7"
}

asciidoctor {
    attributes "snippets": snippetsDir,
            "version": version,
            "date": new SimpleDateFormat("yyyy-MM-dd").format(new Date()),
            "stylesheet": "themes/riak.css"
    inputs.dir snippetsDir
    dependsOn test
    sourceDir "src/main/asciidoc"
    outputDir "build/docs"
}

gitPublish {
    repoUri = "https://github.com/adessoAG/coderadar.git"
    branch = "gh-pages"
    contents {
        from "build/pages"
        into "current/docs"
    }
    commitMessage = "automatically updated docs"
}

task preparePages() {
    doLast {
        copy {
            from "build/docs/html5"
            into "build/pages"
        }
    }
}

jar {
    dependsOn asciidoctor
    from("${asciidoctor.outputDir}/html5") {
        into "static/docs"
    }
}

preparePages.dependsOn asciidoctor
