apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'corda.common-publishing'

description 'Corda node web server'

configurations {
    integrationTestImplementation.extendsFrom testImplementation
    integrationTestRuntime.extendsFrom testRuntimeOnly
}

sourceSets {
    integrationTest {
        kotlin {
            compileClasspath += main.output + test.output
            runtimeClasspath += main.output + test.output
            srcDir file('src/integration-test/kotlin')
        }
    }
}

processResources {
    from file("$rootDir/config/dev/log4j2.xml")
}

dependencies {
    implementation project(':core')
    implementation project(':node-api')
    implementation project(':client:rpc')
    implementation project(':client:jackson')
    implementation project(':tools:cliutils')
    implementation project(":common-logging")

    // Web stuff: for HTTP[S] servlets
    implementation "org.eclipse.jetty.ee10:jetty-ee10-servlet:$jetty_version"
    implementation "org.eclipse.jetty.ee10:jetty-ee10-webapp:$jetty_version"
    //implementation "javax.servlet:javax.servlet-api:${servlet_version}"
    implementation "org.apache.commons:commons-fileupload2-jakarta:$fileupload_version"

    // Log4J: logging framework (with SLF4J bindings)
    implementation "org.apache.logging.log4j:log4j-slf4j2-impl:$log4j_version"
    implementation "org.apache.logging.log4j:log4j-core:$log4j_version"

    // JOpt: for command line flags.
    implementation "net.sf.jopt-simple:jopt-simple:$jopt_simple_version"

    implementation "org.glassfish.jersey.core:jersey-server:$jersey_version"
    implementation "org.glassfish.jersey.containers:jersey-container-servlet:$jersey_version"
    implementation "org.glassfish.jersey.containers:jersey-container-jetty-http:$jersey_version"
    implementation "org.glassfish.jersey.media:jersey-media-json-jackson:$jersey_version"
    implementation "org.glassfish.jersey.inject:jersey-hk2:$jersey_version"

    // For rendering the index page.
    implementation "org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.12"

    // Capsule is a library for building independently executable fat JARs.
    // We only need this dependency to implementation our Caplet against.
    implementation "co.paralleluniverse:capsule:$capsule_version"

    implementation group: "com.typesafe", name: "config", version: typesafe_config_version
    implementation "com.google.guava:guava:$guava_version"

    implementation "io.netty:netty-transport-native-unix-common:4.1.77.Final.jar"


    testImplementation project(":core-test-utils")

    testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_jupiter_version}"
    testImplementation "junit:junit:$junit_version"

    testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junit_vintage_version}"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_jupiter_version}"
    testRuntimeOnly "org.junit.platform:junit-platform-launcher:${junit_platform_version}"

    integrationTestImplementation project(':node-driver')
}

tasks.register('integrationTest', Test) {
    testClassesDirs = sourceSets.integrationTest.output.classesDirs
    classpath = sourceSets.integrationTest.runtimeClasspath
}

jar {
    baseName 'corda-testserver-impl'
}

compileJava.dependsOn ':node:capsule:buildCordaJAR'
javadoc.dependsOn ':testing:testserver:testcapsule:buildWebserverJar'

publishing {
    publications {
        maven(MavenPublication) {
            artifactId jar.baseName
            from components.java
        }
    }
}
