plugins {
    id "org.sonarqube" version "2.1-rc1"
    id "org.ajoberstar.github-pages" version "1.6.0-rc.1"
    id "org.xbib.gradle.plugin.jbake" version "1.1.0"
}

println "Host: " + java.net.InetAddress.getLocalHost()
println "Gradle: " + gradle.gradleVersion + " JVM: " + org.gradle.internal.jvm.Jvm.current() + " Groovy: " + GroovySystem.getVersion()
println "Build: group: '${project.group}', name: '${project.name}', version: '${project.version}'"

allprojects {

    apply plugin: 'java'
    apply plugin: 'maven'
    apply plugin: 'signing'
    apply plugin: 'findbugs'
    apply plugin: 'pmd'
    apply plugin: 'checkstyle'
    apply plugin: "jacoco"

    repositories {
        mavenLocal()
        mavenCentral()
    }

    configurations {
        wagon
        provided
        testCompile.extendsFrom(provided)
    }

    dependencies {
        testCompile 'junit:junit:4.12'
        wagon 'org.apache.maven.wagon:wagon-ssh-external:2.10'
    }

    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8

    [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:all" << "-profile" << "compact2"
    }
    test {
        classpath += configurations.provided
        testLogging {
            showStandardStreams = false
            exceptionFormat = 'full'
        }
    }
    tasks.withType(FindBugs) {
        ignoreFailures = true
        reports {
            xml.enabled = true
            html.enabled = false
        }
    }
    tasks.withType(Pmd) {
        ignoreFailures = true
        reports {
            xml.enabled = true
            html.enabled = true
        }
    }
    tasks.withType(Checkstyle) {
        ignoreFailures = true
        reports {
            xml.enabled = true
            html.enabled = true
        }
    }
    jacocoTestReport {
        reports {
            xml.enabled true
            csv.enabled false
            xml.destination "${buildDir}/reports/jacoco-xml"
            html.destination "${buildDir}/reports/jacoco-html"
        }
    }

    sonarqube {
        properties {
            property "sonar.projectName", "xbib content"
            property "sonar.sourceEncoding", "UTF-8"
            property "sonar.tests", "src/test/java"
            property "sonar.scm.provider", "git"
            property "sonar.java.coveragePlugin", "jacoco"
            property "sonar.junit.reportsPath", "build/test-results/test/"
        }
    }

    task sourcesJar(type: Jar, dependsOn: classes) {
        classifier 'sources'
        from sourceSets.main.allSource
    }
    task javadocJar(type: Jar, dependsOn: javadoc) {
        classifier 'javadoc'
    }
    artifacts {
        archives sourcesJar, javadocJar
    }
    if (project.hasProperty('signing.keyId')) {
        signing {
            sign configurations.archives
        }
    }

    apply from: "${rootProject.projectDir}/gradle/ext.gradle"
    apply from: "${rootProject.projectDir}/gradle/publish.gradle"

}
