plugins {
    id 'application'
    id 'com.diffplug.spotless' version '6.25.0'
    id 'jacoco'
}

application {
    mainClass = 'org.apache.couchdb.nouveau.NouveauApplication'
}

repositories {
    mavenLocal()
    maven {
        url = uri('https://repo.maven.apache.org/maven2/')
    }
}

dependencies {
    implementation platform('io.dropwizard:dropwizard-dependencies:4.0.12')
    implementation 'io.dropwizard:dropwizard-core'
    implementation 'io.dropwizard:dropwizard-http2'
    implementation 'io.dropwizard.metrics:metrics-core'
    implementation 'io.dropwizard.metrics:metrics-jersey2'
    testImplementation 'io.dropwizard:dropwizard-testing'

    def luceneVersion = '9.12.1'
    implementation group: 'org.apache.lucene', name: 'lucene-core', version: luceneVersion
    implementation group: 'org.apache.lucene', name: 'lucene-queryparser', version: luceneVersion
    implementation group: 'org.apache.lucene', name: 'lucene-analysis-common', version: luceneVersion
    implementation group: 'org.apache.lucene', name: 'lucene-analysis-stempel', version: luceneVersion
    implementation group: 'org.apache.lucene', name: 'lucene-analysis-smartcn', version: luceneVersion
    implementation group: 'org.apache.lucene', name: 'lucene-analysis-kuromoji', version: luceneVersion
    implementation group: 'org.apache.lucene', name: 'lucene-facet', version: luceneVersion
    implementation group: 'org.apache.lucene', name: 'lucene-misc', version: luceneVersion
    implementation group: 'org.apache.lucene', name: 'lucene-backward-codecs', version: luceneVersion

    def swaggerVersion = '2.2.8'
    implementation group: 'io.swagger.core.v3', name: 'swagger-jaxrs2-jakarta', version: swaggerVersion
    implementation group: 'io.swagger.core.v3', name: 'swagger-jaxrs2-servlet-initializer-v2', version: swaggerVersion

    testImplementation 'org.assertj:assertj-core'
    testImplementation 'org.mockito:mockito-core'
}

group = 'org.apache.couchdb'
version = '1.0-SNAPSHOT'

java {
    sourceCompatibility = "11"
}

jar {
    manifest {
        attributes(
            'Multi-Release': 'true',
            'Main-Class': application.mainClass,
            'Enable-Native-Access': 'ALL-UNNAMED',
            "Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' '))
    }
}

spotless {
  java {
    importOrder()
    removeUnusedImports()
    cleanthat()
    palantirJavaFormat()
  }
}

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

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

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

tasks.withType(AbstractArchiveTask) {
    preserveFileTimestamps = false
    reproducibleFileOrder = true
}


startScripts {
    enabled = false
}
