plugins {
    id 'application'
    id 'com.diffplug.spotless' version '8.0.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.17')
    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 = '10.4.0'
    implementation 'org.apache.lucene:lucene-core:' + luceneVersion
    implementation 'org.apache.lucene:lucene-queryparser:' + luceneVersion
    implementation 'org.apache.lucene:lucene-analysis-common:' + luceneVersion
    implementation 'org.apache.lucene:lucene-analysis-stempel:' + luceneVersion
    implementation 'org.apache.lucene:lucene-analysis-smartcn:' + luceneVersion
    implementation 'org.apache.lucene:lucene-analysis-kuromoji:' + luceneVersion
    implementation 'org.apache.lucene:lucene-facet:' + luceneVersion
    implementation 'org.apache.lucene:lucene-misc:' + luceneVersion
    implementation 'org.apache.lucene:lucene-backward-codecs:' + luceneVersion

    def swaggerVersion = '2.2.8'
    implementation 'io.swagger.core.v3:swagger-jaxrs2-jakarta:' + swaggerVersion
    implementation 'io.swagger.core.v3:swagger-jaxrs2-servlet-initializer-v2:' + swaggerVersion

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

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

java {
    sourceCompatibility = "21"
}

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()
    forbidWildcardImports()
    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
}
