/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

plugins {
    id 'eclipse'
    id 'maven-publish'
    id 'org.scoverage'
    id 'scala'
    id 'java-library'
}

ext.dockerImageName = 'scala'

// Using a multiarch base image should make this supefluous
//if(System.getProperty("os.arch").toLowerCase(Locale.ENGLISH).startsWith("aarch")) {
//    ext.dockerDockerfileSuffix = ".arm"
//}

apply from: '../../gradle/docker.gradle'

project.archivesBaseName = "openwhisk-common"

scoverage {
    scoverageVersion.set("${gradle.scala.scoverageVersion}")
    scoverageScalaVersion.set("${gradle.scala.scoverageScalaVersion}")
}

dependencies {
    api "org.scala-lang:scala-library:${gradle.scala.version}"

    api ("com.github.pureconfig:pureconfig_${gradle.scala.depVersion}:0.11.1") {
        exclude group: 'org.scala-lang', module: 'scala-compiler'
        exclude group: 'org.scala-lang', module: 'scala-reflect'
    }
    api "io.spray:spray-json_${gradle.scala.depVersion}:1.3.5"
    api "com.lihaoyi:fastparse_${gradle.scala.depVersion}:2.3.0"
    api "com.typesafe.akka:akka-actor_${gradle.scala.depVersion}:${gradle.akka.version}"
    api "com.typesafe.akka:akka-stream_${gradle.scala.depVersion}:${gradle.akka.version}"
    api "com.typesafe.akka:akka-slf4j_${gradle.scala.depVersion}:${gradle.akka.version}"
    api "com.typesafe.akka:akka-cluster_${gradle.scala.depVersion}:${gradle.akka.version}"
    api "com.typesafe.akka:akka-cluster-metrics_${gradle.scala.depVersion}:${gradle.akka.version}"
    api "com.typesafe.akka:akka-cluster-tools_${gradle.scala.depVersion}:${gradle.akka.version}"
    api "com.typesafe.akka:akka-distributed-data_${gradle.scala.depVersion}:${gradle.akka.version}"

    api "com.typesafe.akka:akka-http-core_${gradle.scala.depVersion}:${gradle.akka_http.version}"
    api "com.typesafe.akka:akka-http-spray-json_${gradle.scala.depVersion}:${gradle.akka_http.version}"

    api "com.lightbend.akka:akka-stream-alpakka-file_${gradle.scala.depVersion}:2.0.2"

    api "ch.qos.logback:logback-classic:1.2.13"
    api "org.slf4j:jcl-over-slf4j:1.7.25"
    api "org.slf4j:log4j-over-slf4j:1.7.25"
    api "commons-codec:commons-codec:1.9"
    api "commons-io:commons-io:2.14.0"
    api "commons-collections:commons-collections:3.2.2"
    api "org.apache.kafka:kafka-clients:2.8.2"
    api "org.apache.httpcomponents:httpclient:4.5.5"
    api "com.fasterxml.uuid:java-uuid-generator:3.1.3"
    api "com.github.ben-manes.caffeine:caffeine:2.6.2"
    api "com.google.code.findbugs:jsr305:3.0.2"
    api "io.fabric8:kubernetes-client:${gradle.kube_client.version}"

    //metrics
    api ("io.kamon:kamon-core_${gradle.scala.depVersion}:2.1.12") {
        exclude group: 'com.lihaoyi'
    }
    api "io.kamon:kamon-statsd_${gradle.scala.depVersion}:2.1.12"
    api ("io.kamon:kamon-system-metrics_${gradle.scala.depVersion}:2.1.12") {
        exclude group: 'io.kamon', module: 'sigar-loader'
    }
    api "io.kamon:kamon-prometheus_${gradle.scala.depVersion}:2.1.12"
    api "io.kamon:kamon-datadog_${gradle.scala.depVersion}:2.1.12"

    // for etcd
    api "com.ibm.etcd:etcd-java:0.0.13"

    //tracing support
    api "io.opentracing:opentracing-api:0.31.0"
    api "io.opentracing:opentracing-util:0.31.0"
    api ("io.opentracing.brave:brave-opentracing:0.31.0") {
        exclude group: 'io.zipkin.brave', module:'brave-tests'
    }
    api "io.zipkin.reporter2:zipkin-sender-okhttp3:2.6.1"
    api "io.zipkin.reporter2:zipkin-reporter:2.6.1"

    api "io.reactivex:rxjava:1.3.8"
    api "io.reactivex:rxjava-reactive-streams:1.2.1"


    api ("com.lightbend.akka:akka-stream-alpakka-s3_${gradle.scala.depVersion}:1.1.2") {
        exclude group: 'org.apache.httpcomponents' //Not used as alpakka uses akka-http
        exclude group: 'com.fasterxml.jackson.core'
        exclude group: 'com.fasterxml.jackson.dataformat'
    }
    api "com.amazonaws:aws-java-sdk-cloudfront:1.12.792" // Upgraded to remove ion-java dependency (CVE-2024-21634)

    api ("com.azure:azure-storage-blob:12.7.0") {
        exclude group: "com.azure", module: "azure-core-test"
    }

    api "com.microsoft.azure:azure-cosmosdb:2.6.2"
    constraints {
        api("com.microsoft.azure:azure-cosmosdb:2.6.2")
        api("com.fasterxml.jackson.core:jackson-core:2.15.4") {
            because "cannot upgrade azure-cosmosdb to new major version to remediate vulns w/o breaking change"
        }
    }

    api "com.sksamuel.elastic4s:elastic4s-http_${gradle.scala.depVersion}:6.7.8"
    constraints {
        api("com.sksamuel.elastic4s:elastic4s-http_${gradle.scala.depVersion}:6.7.8")
        api("org.elasticsearch.client:elasticsearch-rest-client:6.8.23") {
            because "cannot upgrade elastic4s to remediate vuln without performing major version rest client upgrade"
        }
    }
    //for mongo
    api "org.mongodb.scala:mongo-scala-driver_${gradle.scala.depVersion}:2.7.0"
    constraints {
        api("org.mongodb.scala:mongo-scala-driver_${gradle.scala.depVersion}:2.7.0")
        api("org.mongodb:mongodb-driver-async:3.12.1") {
            because "cannot upgrade major mongo scala driver to remediate vuln w/o code changes"
        }
    }

    api "io.netty:netty-buffer:${gradle.netty.version}"
    api "io.netty:netty-handler:${gradle.netty.version}"
    api "io.netty:netty-handler-proxy:${gradle.netty.version}"
    api "io.netty:netty-codec-socks:${gradle.netty.version}"
    api "io.netty:netty-codec-http:${gradle.netty.version}"
    api "io.netty:netty-codec-http2:${gradle.netty.version}"
    api "io.netty:netty-transport-native-epoll:${gradle.netty.version}"
    api "io.netty:netty-transport-native-unix-common:${gradle.netty.version}"
    api "com.lightbend.akka.grpc:akka-grpc-runtime_${gradle.scala.depVersion}:${gradle.akka_gprc.version}"
    api "com.typesafe.akka:akka-stream_${gradle.scala.depVersion}:${gradle.akka.version}"

    // Constraints for transitive dependencies to address security vulnerabilities
    constraints {
        api("org.apache.commons:commons-text:1.10.0")
        api("com.google.code.gson:gson:2.8.9")

        api("com.google.protobuf:protobuf-java:3.25.5")
        api("org.xerial.snappy:snappy-java:1.1.10.4")
        api("ch.qos.logback:logback-core:1.2.13")
        api("io.netty:netty-codec:${gradle.netty.version}")
        api("io.netty:netty-common:${gradle.netty.version}")
    }
}

configurations {
    api {
        exclude group: 'commons-logging'
        exclude group: 'log4j'
    }
}
