def libs = ext.libs = [:]
def versions = ext.libsVersions = [:]

// versions
versions.guice = "5.1.0"
versions.guava = "33.3.1-jre"
versions.hibernate = "5.6.15.Final"
versions.hibernate_validator = "6.2.5.Final"

versions.groovy = "3.0.24"
versions.resteasy = "4.7.9.Final"
versions.jackson = "2.18.3"
versions.shiro = "1.13.0"
versions.buji_pac4j = "8.1.1"
versions.javaee_pac4j = "7.1.0"
versions.pac4j = "5.7.7"
versions.ldaptive = "2.3.2"

versions.junit4 = "4.13.2"
versions.junit5 = "5.11.4"

versions.slf4j = "2.0.17"

versions.tomcat = "9.0.102"
versions.tomcat_embed = "${versions.tomcat}"

versions.asm = "9.7.1"

// unit testing
libs.junit = "junit:junit:${versions.junit4}"
libs.junit_jupiter = "org.junit.jupiter:junit-jupiter:${versions.junit5}"
libs.junit_vintage = "org.junit.vintage:junit-vintage-engine:${versions.junit5}" // junit4 compatibility
libs.junit_launcher = "org.junit.platform:junit-platform-launcher:1.11.4" // for IDE

// logging
libs.slf4j_api = "org.slf4j:slf4j-api:${versions.slf4j}"

libs.slf4j_base = [
  libs.slf4j_api,
  "org.slf4j:jul-to-slf4j:${versions.slf4j}",
  "org.slf4j:jcl-over-slf4j:${versions.slf4j}",
  "org.slf4j:log4j-over-slf4j:${versions.slf4j}"
]

libs.slf4j_logback = libs.slf4j_base + [
  "ch.qos.logback:logback-core:1.3.15",
  "ch.qos.logback:logback-classic:1.3.15",
  "org.fusesource.jansi:jansi:2.4.1"
]

// Guava
libs.guava = [
  "com.google.guava:guava:${versions.guava}",
  "com.google.code.findbugs:jsr305:3.0.2"
]

// yaml
libs.snakeyaml = "org.yaml:snakeyaml:2.3"

// Guice
libs.guice = "com.google.inject:guice:${versions.guice}"
libs.guice_servlet = "com.google.inject.extensions:guice-servlet:${versions.guice}"
libs.guice_persist = "com.google.inject.extensions:guice-persist:${versions.guice}"

// ASM
libs.asm = [
  "org.ow2.asm:asm:${versions.asm}",
  "org.ow2.asm:asm-commons:${versions.asm}",
  "org.ow2.asm:asm-util:${versions.asm}",
  "org.ow2.asm:asm-tree:${versions.asm}",
  "org.ow2.asm:asm-analysis:${versions.asm}"
]

// Byte Buddy
libs.byte_buddy = "net.bytebuddy:byte-buddy:1.15.10"

// Graal JS
libs.graal_js = "org.graalvm.js:js:22.3.5"

// javax libs
libs.javax_jaxb = "javax.xml.bind:jaxb-api:2.3.1"
libs.javax_servlet = "javax.servlet:javax.servlet-api:4.0.1"
libs.javax_validation = "javax.validation:validation-api:2.0.1.Final"
libs.javax_el = ["org.apache.tomcat:tomcat-jasper:${versions.tomcat}", "org.apache.tomcat:tomcat-el-api:${versions.tomcat}"]
libs.javax_mail = "com.sun.mail:javax.mail:1.6.2"
libs.greenmail = "com.icegreen:greenmail-junit5:1.6.15"
libs.javax_el = "org.glassfish:jakarta.el:3.0.4"
libs.websocket_api = "javax.websocket:javax.websocket-api:1.1"

// jdbc
libs.jdbc_hsqldb = "org.hsqldb:hsqldb:2.7.4"
//v42.7.5: performance issue: https://github.com/pgjdbc/pgjdbc/issues/3511
libs.jdbc_postgres = "org.postgresql:postgresql:42.7.4"
libs.jdbc_mysql = "com.mysql:mysql-connector-j:8.4.0"

// Hibernate
libs.hibernate = [
  "org.hibernate:hibernate-core:${versions.hibernate}",
  "org.hibernate:hibernate-hikaricp:${versions.hibernate}",
  "org.hibernate.validator:hibernate-validator:${versions.hibernate_validator}",
  "org.hibernate:hibernate-jcache:${versions.hibernate}"
]

// Caching libs
libs.ehcache = "org.ehcache:ehcache:3.10.8"
libs.redisson = [
    dependencies.create("org.redisson:redisson-hibernate-53:3.38.1") {
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
        exclude group: "com.fasterxml.jackson.dataformat", module: "jackson-dataformat-yaml"
    },
    // overrides jackson version used
    "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
]
libs.hazelcast = "com.hazelcast:hazelcast:5.3.8"
libs.caffeine = "com.github.ben-manes.caffeine:jcache:3.1.6"
libs.infinispan = [
    "org.infinispan:infinispan-hibernate-cache-v53:13.0.22.Final",
    "org.infinispan:infinispan-core:13.0.22.Final",
    "org.infinispan:infinispan-jcache:13.0.22.Final"
]

// apache tika
libs.apache_tika_core = "org.apache.tika:tika-core:2.9.2"

// flyway
libs.flywaydb = [
    dependencies.create("org.flywaydb:flyway-core:9.22.3") {
        exclude group: 'com.fasterxml.jackson.dataformat', module: 'jackson-dataformat-toml'
    },
    // overrides jackson version used
    "com.fasterxml.jackson.dataformat:jackson-dataformat-toml:${versions.jackson}"
]

// eclipselink
libs.eclipselink_moxy = "org.eclipse.persistence:org.eclipse.persistence.moxy:2.7.15"

// groovy
libs.groovy = [
  "org.codehaus.groovy:groovy:${versions.groovy}",
  "org.codehaus.groovy:groovy-jsr223:${versions.groovy}",
  "org.codehaus.groovy:groovy-templates:${versions.groovy}",
  "org.codehaus.groovy:groovy-datetime:${versions.groovy}",
  "org.codehaus.groovy:groovy-nio:${versions.groovy}",
  "org.codehaus.groovy:groovy-xml:${versions.groovy}",
  "org.codehaus.groovy:groovy-json:${versions.groovy}"
]

def resteasy_module = { name ->
    dependencies.create("org.jboss.resteasy:${name}:${versions.resteasy}") {
        exclude module: "smallrye-config"
        exclude module: "resteasy-jaxb-provider"
        exclude group: "com.fasterxml.jackson.core", module: "jackson-core"
        exclude group: "com.fasterxml.jackson.core", module: "jackson-databind"
        exclude group: "com.fasterxml.jackson.core", module: "jackson-annotations"
        exclude group: "com.fasterxml.jackson.jaxrs", module: "jackson-jaxrs-json-provider"
        exclude module: "mail", group: "javax.mail"
    }
}

// jax-rs
libs.resteasy = [
    resteasy_module("resteasy-core"),
    resteasy_module("resteasy-jackson2-provider"),
    "io.smallrye.config:smallrye-config:1.13.1"
]

libs.resteasy_multipart = resteasy_module("resteasy-multipart-provider")
libs.resteasy_guice = resteasy_module("resteasy-guice")
libs.resteasy_client = resteasy_module("resteasy-client")
libs.resteasy_server = [
  "org.jboss.resteasy:resteasy-undertow:${versions.resteasy}",
  "io.undertow:undertow-core:2.2.37.Final",
  "io.undertow:undertow-servlet:2.2.37.Final"
]

libs.swagger_jaxrs2 = [
    dependencies.create("io.swagger.core.v3:swagger-jaxrs2:2.2.28") {
        exclude group: "com.fasterxml.jackson.core", module: "jackson-databind"
        exclude group: "com.fasterxml.jackson.core", module: "jackson-annotations"
        exclude group: "com.fasterxml.jackson.jaxrs", module: "jackson-jaxrs-json-provider"
        exclude group: "com.fasterxml.jackson.datatype", module: "jackson-datatype-jsr310"
        exclude group: "com.fasterxml.jackson.dataformat", module: "jackson-dataformat-yaml"
    },
    // overrides jackson version used
    "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
]

// jackson
libs.jackson_libs = [
  "com.fasterxml.jackson.core:jackson-core:${versions.jackson}",
  "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}",
  "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}",
  "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:${versions.jackson}",
  "com.fasterxml.jackson.datatype:jackson-datatype-guava:${versions.jackson}",
  "com.fasterxml.jackson.module:jackson-module-parameter-names:${versions.jackson}",
  "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${versions.jackson}",
  "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${versions.jackson}"
]

// Apache Shiro
libs.apache_shiro = [
  "org.apache.shiro:shiro-core:${versions.shiro}",
  "org.apache.shiro:shiro-web:${versions.shiro}",
  "org.apache.shiro:shiro-guice:${versions.shiro}"
]

libs.pac4j = [
  "io.buji:buji-pac4j:${versions.buji_pac4j}",
  "org.pac4j:javaee-pac4j:${versions.javaee_pac4j}",
  dependencies.create("org.pac4j:pac4j-http:${versions.pac4j}") {
      exclude group: "com.fasterxml.jackson.core", module: "jackson-databind"
  },
  dependencies.create("org.pac4j:pac4j-ldap:${versions.pac4j}") {
      exclude group: "com.fasterxml.jackson.core", module: "jackson-databind"
  },
  "org.ldaptive:ldaptive:${versions.ldaptive}"
]

libs.buji_pac4j = [
  "io.buji:buji-pac4j:${versions.buji_pac4j}",
  "org.pac4j:javaee-pac4j:${versions.javaee_pac4j}",
]

// UnboundID LDAP SDK (for testing only)
libs.unboundid_ldapsdk = 'com.unboundid:unboundid-ldapsdk:6.0.11'

// commons
libs.commons_cli = "commons-cli:commons-cli:1.9.0"
libs.commons_jxpath = "commons-jxpath:commons-jxpath:1.3"
libs.commons_csv = [
  "org.apache.commons:commons-csv:1.12.0",
  "commons-io:commons-io:2.18.0"
]

// BIRT Runtime
libs.birt_runtime = [
  dependencies.create("org.eclipse.birt.runtime:org.eclipse.birt.runtime:4.4.2") {
    exclude module: "derby"
    exclude module: "org.eclipse.datatools.connectivity.apache.derby"
    exclude module: "org.eclipse.datatools.connectivity.apache.derby.dbdefinition"
    exclude module: "org.apache.batik.pdf" // causing issue with commons-io
    exclude module: "commons-cli"
    exclude module: "xml-apis"
    exclude module: "javax.xml.stream"
    exclude module: "org.w3c.dom.smil"
    exclude module: "org.apache.xerces"
    exclude module: "xmlbeans"
    exclude module: "flute"
    exclude module: "org.apache.commons.codec"
    exclude module: "com.ibm.icu"
  },
  // overrides
  dependencies.create("xerces:xercesImpl:2.12.2") {
    exclude module: "xml-apis"
  },
  "milyn:flute:1.3",
  "org.apache.xmlbeans:xmlbeans:3.1.0"
]

// Quartz Scheduler
libs.quartz = dependencies.create("org.quartz-scheduler:quartz:2.4.0") {
  exclude module: "c3p0"
}

// xstream
libs.xstream = [
  "com.thoughtworks.xstream:xstream:1.4.21",
  "com.fasterxml.woodstox:woodstox-core:6.7.0"
]

// jsoup for html parsing & sanitize
libs.jsoup = "org.jsoup:jsoup:1.18.3"

// StringTemplate
libs.ST4 = "org.antlr:ST4:4.3.4"

// gradle plugins
libs.plugin_license = "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.16.1"

// embeded tomcat
libs.tomcat_embed = [
  "org.apache.tomcat.embed:tomcat-embed-core:${versions.tomcat_embed}",
  "org.apache.tomcat.embed:tomcat-embed-jasper:${versions.tomcat_embed}",
  "org.apache.tomcat.embed:tomcat-embed-websocket:${versions.tomcat_embed}",
  libs.javax_el
]

libs.jasypt = "org.jasypt:jasypt:1.9.3"
