plugins {
	id 'java'
    id 'io.franzbecker.gradle-lombok' version '5.0.0'
    id 'checkstyle'
    id 'com.vanniktech.maven.publish' version '0.18.0'
    id 'jacoco'
    id "org.sonarqube" version "3.4.0.2513"
}

compileJava {
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"
}

compileTestJava {
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.code.gson:gson:2.9.0'
    compileOnly "org.projectlombok:lombok:1.18.24"
    annotationProcessor 'org.projectlombok:lombok:1.18.24'
    testCompileOnly 'org.projectlombok:lombok:1.18.24'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
    testImplementation 'org.mockito:mockito-core:4.6.1'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
    testImplementation 'org.assertj:assertj-core:3.22.0'
    testImplementation 'com.github.tomakehurst:wiremock:2.27.2'
    testImplementation 'org.slf4j:slf4j-api:1.7.36'
    testImplementation 'org.slf4j:slf4j-simple:1.7.36'
}

checkstyle {
    toolVersion = '8.8'
}

import io.franzbecker.gradle.lombok.task.DelombokTask

task delombok(type: DelombokTask, dependsOn: compileJava) {
    ext.outputDir = file("$buildDir/delombok")
    outputs.dir(outputDir)
    sourceSets.main.java.srcDirs.each {
        inputs.dir(it)
        args(it, "-d", outputDir)
    }
}

javadoc {
    dependsOn delombok
    source = delombok.outputDir
    failOnError = false
    options.memberLevel = JavadocMemberLevel.PUBLIC
}

jacoco {
    toolVersion = "0.8.7"
}

test.finalizedBy jacocoTestReport

test {
    useJUnitPlatform()
    reports {
        junitXml.enabled = false
        html.enabled = true
    }
}

signing {
    if (project.hasProperty('SIGNING_PRIVATE_KEY') && project.hasProperty('SIGNING_PASSWORD')) {
        useInMemoryPgpKeys(project.getProperty('SIGNING_PRIVATE_KEY'), project.getProperty('SIGNING_PASSWORD'))
    }
}

sonarqube {
  properties {
    property "sonar.projectKey", "amadeus4dev_amadeus-java"
    property "sonar.organization", "amadeus4dev"
    property "sonar.host.url", "https://sonarcloud.io"
  }
}
