plugins {
    id 'java'
}

allprojects {
    group 'com.apress.cems'
    version '1.2-SNAPSHOT'
}

subprojects {
    repositories {
        mavenLocal()
        jcenter()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://repo.spring.io/snapshot/" }
        maven { url "https://repo.spring.io/milestone" }
        maven { url "https://plugins.gradle.org/m2/" }
        maven {url "https://projectlombok.org/edge-releases"}
    }
}

java.sourceCompatibility = JavaVersion.VERSION_13

ext {
    springVersion = '5.2.3.RELEASE'
    springBootVersion = '2.2.4.RELEASE'
    springJpaVersion = '2.2.4.RELEASE'
    springSecurityVersion = '5.2.1.RELEASE'
    springCloudVersion = '2.2.1.RELEASE'
    cloudReleaseTrainVersion = 'Hoxton.SR1'
    springBootR2dbcVersion = '0.1.0.M3'

    aspectjVersion = '1.9.5'
    jacksonVersion = '2.10.2'
    hikariVersion = '3.4.2'
    hibernateVersion = '5.4.10.Final'
    reactorVersion = '3.3.2.RELEASE'
    nettyVersion = '0.9.4.RELEASE'
    r2dbcH2Version = '0.8.2.RELEASE'

    //logging
    slf4jVersion = '2.0.0-alpha1'
    logbackVersion = '1.3.0-alpha5'

    //view technologies
    thymeleafVersion = '3.0.11.RELEASE'
    jacksonVersion = '2.10.2'
    poiVersion = '4.1.1'
    itextVersion = '5.5.13.1'

    tomcatVersion = '9.0.22'
    lang3Version = '3.8.1'
    prometheusVersion = '1.2.0'

    //testing
    h2Version = '2.0.206'
    junitVersion ='4.13'
    junit5Version = '5.6.0'
    junit5PlatformVersion = '1.6.0'
    easymockVersion ='4.2'
    jmockVersion ='2.12.0'
    mockitoAllVersion ='2.0.2-beta'
    mockitoVersion = '3.2.4'
    mongoVersion = '2.2.0'
    restAssuredVersion = '4.2.0'
    hamcrestVersion = '2.1'

    boot = [
            springBootPlugin: "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion",
            starterWeb      : "org.springframework.boot:spring-boot-starter-web:$springBootVersion",
            starterWebflux      : "org.springframework.boot:spring-boot-starter-webflux:$springBootVersion",
            starterJetty    : "org.springframework.boot:spring-boot-starter-jetty:$springBootVersion",
            starterJpa      : "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion",
            starterMongo    : "org.springframework.boot:spring-boot-starter-data-mongodb:$springBootVersion",
            starterMongoReactive    : "org.springframework.boot:spring-boot-starter-data-mongodb-reactive:$springBootVersion",
            starterTest     : "org.springframework.boot:spring-boot-starter-test:$springBootVersion",
            actuator        : "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion",
            devtools        : "org.springframework.boot:spring-boot-devtools:$springBootVersion",
            starterThymeleaf: "org.springframework.boot:spring-boot-starter-thymeleaf:$springBootVersion",
            starterMustache : "org.springframework.boot:spring-boot-starter-mustache:$springBootVersion",
            prometheus      : "io.micrometer:micrometer-registry-prometheus:$prometheusVersion",
            starterSecurity : "org.springframework.boot:spring-boot-starter-security:$springBootVersion",
            r2dbcBom        : "org.springframework.boot.experimental:spring-boot-bom-r2dbc:$springBootR2dbcVersion",
            starterR2dbc    : "org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:$springBootR2dbcVersion",
            r2dbcTest       : "org.springframework.boot.experimental:spring-boot-test-autoconfigure-r2dbc:$springBootR2dbcVersion"
    ]

    spring = [
            beans          : "org.springframework:spring-beans:$springVersion",
            aop          : "org.springframework:spring-aop:$springVersion",
            contextSupport : "org.springframework:spring-context-support:$springVersion",
            orm            : "org.springframework:spring-orm:$springVersion",
            jdbc           : "org.springframework:spring-jdbc:$springVersion",
            web            : "org.springframework:spring-web:$springVersion",
            webmvc         : "org.springframework:spring-webmvc:$springVersion",
            securityWeb    : "org.springframework.security:spring-security-web:$springSecurityVersion",
            securityTaglibs: "org.springframework.security:spring-security-taglibs:$springSecurityVersion",
            securityConfig : "org.springframework.security:spring-security-config:$springSecurityVersion",
            securityTest   : "org.springframework.security:spring-security-test:$springSecurityVersion",
            test           : "org.springframework:spring-test:$springVersion",
            data           : "org.springframework.data:spring-data-jpa:$springJpaVersion",
            mongo          : "org.springframework.data:spring-data-mongodb:$springJpaVersion"
    ]

    cloud = [
            dataCommons   : "org.springframework.data:spring-data-commons:$springJpaVersion",
            cloudStarter  : "org.springframework.cloud:spring-cloud-starter-config:$springCloudVersion",
            eurekaServer  : "org.springframework.cloud:spring-cloud-starter-netflix-eureka-server:$springCloudVersion",
            eurekaClient  : "org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:$springCloudVersion",
            bom           : "org.springframework.cloud:spring-cloud-dependencies:$cloudReleaseTrainVersion"
    ]

    hibernate = [
            validator : "org.hibernate:hibernate-validator:6.1.2.Final",
            ehcache   : "org.hibernate:hibernate-ehcache:$hibernateVersion",
            em        : "org.hibernate:hibernate-entitymanager:$hibernateVersion",
            core      : "org.hibernate:hibernate-core:$hibernateVersion",
            javaxELApi: "org.glassfish:javax.el:3.0.1-b11"
    ]

    misc  = [
            aspectjweaver    : "org.aspectj:aspectjweaver:$aspectjVersion",
            h2               : "com.h2database:h2:$h2Version",
            jsr250           : "javax.annotation:javax.annotation-api:1.3.2",
            inject           : "javax.inject:javax.inject:1",
            ojdbc            : "com.oracle.ojdbc:ojdbc8:19.3.0.0",
            hikari           : "com.zaxxer:HikariCP:$hikariVersion",
            lang3            : "org.apache.commons:commons-lang3:3.9",
            slf4j            : "org.slf4j:slf4j-api:$slf4jVersion",
            logback          : "ch.qos.logback:logback-classic:$logbackVersion",
            javaxValidation  : "javax.validation:validation-api:2.0.1.Final",
            jacksonDatabind  : "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
            jacksonJsr310    : "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion",
            javaxPersistence : "org.eclipse.persistence:javax.persistence:2.2.1",
            jstl             : "javax.servlet:jstl:1.2",
            servletApi       : "javax.servlet:javax.servlet-api:4.0.1",
            poi              : "org.apache.poi:poi:$poiVersion",
            itext            : "com.itextpdf:itextpdf:$itextVersion",
            jaxbApi          : "javax.xml.bind:jaxb-api:2.4.0-b180830.0359",
            thymeleaf        : "org.thymeleaf:thymeleaf-spring5:$thymeleafVersion",
            thymeleafSecurity: "org.thymeleaf.extras:thymeleaf-extras-springsecurity5:3.0.4.RELEASE",
            //lombok           : "org.projectlombok:lombok:edge-SNAPSHOT",
            projectReactor   : "io.projectreactor:reactor-core:$reactorVersion",
            r2dbcH2          : "io.r2dbc:r2dbc-h2:$r2dbcH2Version"
    ]

    testing = [
            junit         : "junit:junit:$junitVersion",
            api           : "org.junit.jupiter:junit-jupiter-api:$junit5Version",
            engine        : "org.junit.jupiter:junit-jupiter-engine:$junit5Version",
            platformRunner: "org.junit.platform:junit-platform-runner:$junit5PlatformVersion",
            vintageEngine : "org.junit.vintage:junit-vintage-engine:$junit5Version",
            easymock      : "org.easymock:easymock:$easymockVersion",
            hamcrest      : "org.hamcrest:hamcrest:$hamcrestVersion",
            jmockju4      : "org.jmock:jmock-junit4:$jmockVersion",
            jmockju5      : "org.jmock:jmock-junit5:$jmockVersion",
            mockitoAll    : "org.mockito:mockito-all:$mockitoAllVersion",
            mockito       : "org.mockito:mockito-junit-jupiter:$mockitoVersion",
            mongo         : "de.flapdoodle.embed:de.flapdoodle.embed.mongo:$mongoVersion",
            restAssured   : "io.rest-assured:rest-assured:$restAssuredVersion",
            reactorTest   : "io.projectreactor:reactor-test:$reactorVersion",
            springMockMvc : "io.rest-assured:spring-mock-mvc:$restAssuredVersion",
            nettyReactor  : "io.projectreactor.netty:reactor-netty:$nettyVersion",
            restAssuredAll: "io.rest-assured:rest-assured-all:$restAssuredVersion" // needed because it is not a transitive dep
    ]
}

repositories {
    mavenLocal()
    jcenter()
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "https://repo.spring.io/snapshot/" }
    maven { url "https://repo.spring.io/milestone" }
    maven { url "https://plugins.gradle.org/m2/" }
    maven {url "https://projectlombok.org/edge-releases"}
}

task allDeps {
    doLast {
        description 'Task used to display dependencies for all modules in the project'
        subprojects.each { p ->
            println()
            println " $p.name ".center(60, '*')
            println()
            p.configurations.all.findAll { !it.allDependencies.empty }.each { c ->
                println " ${c.name} ".center(60, '-')
                c.allDependencies.each { dep ->
                    println "$dep.group:$dep.name:$dep.version"
                }
                println "-" * 60
            }
        }
    }
}
