plugins {
    id 'application'
    id 'jacoco'
    id "org.sonarqube" version "3.3"
}

repositories  {
    mavenLocal()
    mavenCentral()
}

dependencies {
    implementation 'ch.qos.logback:logback-core:1.1.2'
    implementation 'ch.qos.logback:logback-classic:1.1.2'
    implementation 'org.mongodb.morphia:morphia:1.1.0'
    //compile 'org.mongodb:mongodb-driver:3.2.2'
    implementation 'org.hibernate:hibernate-core:4.3.8.Final'
    implementation 'org.hibernate:hibernate-entitymanager:4.3.8.Final'
    implementation 'org.hsqldb:hsqldb:2.3.0'
    implementation 'ch.qos.logback:logback-core:1.1.2'
    implementation 'ch.qos.logback:logback-classic:1.1.2'
   	testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
}

def MAIN_CLASS_NAME = 'com.ibtp.kontor.KontorApp'

application {
    mainClassName = MAIN_CLASS_NAME
}

jar {
	manifest {
		attributes('Implementation-Title': 'Kontor Application', 'Implementation-Version': version, 'Main-Class': MAIN_CLASS_NAME)
	}
}

tasks.named('test') {
    useJUnitPlatform() 
}

jacocoTestReport {
    reports {
        xml.enabled true
    }
}

test.finalizedBy jacocoTestReport

sonarqube {
    properties {
        property "sonar.projectKey", "kontor_kontor-java_AX-dd-w3rXuu6JVRvr_g"
        property "sonar.host.url", "https://sonar.thpeetz.de"
        property "sonar.login", "d39622f640a91f501b1e8a73d7d78c4fc412fc98"
        property "sonar.qualitygate.wait", true
        property "sonar.sourceEncoding", "UTF-8"
    }
}

tasks.named('sonarqube').configure {
    dependsOn test
}

//tasks.withType(Checkstyle) {
//    ignoreFailures = true
//    showViolations = false
//    configFile = rootProject.file("config/checkstyle/checkstyle.xml")
//    reports {
//        xml.enabled true
//    }
//}

//tasks.withType(FindBugs) {
//    ignoreFailures = true
//    reports {
//        xml.enabled true
//    }
//}

//pmd {
//    ignoreFailures = true
//}

//build.dependsOn(['jacocoTestReport'])

wrapper {
    gradleVersion = "6.3"
}
