plugins {
    id 'java'
    id 'checkstyle'
    id 'com.diffplug.spotless' version '6.25.0'
}

group = 'com.fishercoder'
version = '1.0-SNAPSHOT'

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

tasks.javadoc {
    options.encoding = 'UTF-8'
}

tasks.compileJava {
    options.encoding = 'UTF-8'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.code.gson:gson:2.10.1'
    implementation 'org.apache.commons:commons-collections4:4.0'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'

    testImplementation 'org.assertj:assertj-core:3.11.1'
    compileOnly 'org.projectlombok:lombok:1.18.32'
    annotationProcessor 'org.projectlombok:lombok:1.18.32'
    testCompileOnly 'org.projectlombok:lombok:1.18.32'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.32'
}

testing {
    suites {
        test {
            useJUnitJupiter()
        }
    }
}

tasks.withType(Test).configureEach {
    maxParallelForks = Runtime.runtime.availableProcessors()
}

checkstyle {
    toolVersion = '6.17'
    config = rootProject.resources.text.fromFile('fishercoder_checkstyle.xml')
}

spotless {
    java {
        encoding 'UTF-8'
        target fileTree(projectDir) {
            include '**/src/**/*.java'
            exclude '**/build/**'
        }
        importOrder '\\#', '', '*'
        removeUnusedImports()
        googleJavaFormat('1.22.0').aosp()
        toggleOffOn()
        endWithNewline()
    }
}
