allprojects {
    version = '1.1-SNAPSHOT'
    group = 'com.ps'

    ext {
        //spring libs
        springVersion = '4.3.3.RELEASE'
        springJpaVersion = '1.10.3.RELEASE'
        springSecurityVersion = '4.1.3.RELEASE'
        springBootVersion = '1.4.1.RELEASE'
        aspectjVersion = '1.8.4'
        yamlVersion = '1.17'

        hessianVersion = '4.0.38'
        burlapVersion = '2.1.12'
        mqVersion = '5.14.1'

        //testing libs
        mockitoVersion = '2.0.2-beta'
        junitVersion = '4.13.2'

        //date library
        jodaVersion = '2.9.2'

        //persistency library
        hibernateVersion = '5.2.1.Final'

        //in memory test database
        h2Version = '1.4.192'

        //logging libs
        logbackVersion = '1.1.7'
        slf4jVersion = '1.7.21'

        //report generating libs
        poiVersion = '3.13'
        jacksonVersion = '2.8.3'

        //aop libs
        aspectjVersion = '1.8.0'

        //we group libraries by their purpose so we can import them easier in the modules
        boot = [
                springBootPlugin: "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion",
                starterWeb      : "org.springframework.boot:spring-boot-starter-web:$springBootVersion",
                starterJetty    : "org.springframework.boot:spring-boot-starter-jetty:$springBootVersion",
                starterSecurity : "org.springframework.boot:spring-boot-starter-security:$springBootVersion",
                starterJpa      : "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion",
                starterTest     : "org.springframework.boot:spring-boot-starter-test:$springBootVersion",
                starterTomcat   : "org.springframework.boot:spring-boot-starter-tomcat:$springBootVersion",
                actuator        : "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion",
                starterWs       : "org.springframework.boot:spring-boot-starter-ws:$springBootVersion",
                yaml            : "org.yaml:snakeyaml:$yamlVersion",
                devtools        : "org.springframework.boot:spring-boot-devtools:$springBootVersion",
                mq              : "org.springframework.boot:spring-boot-starter-activemq:$springBootVersion"
        ]

        tests = [
                junit       : "junit:junit:$junitVersion",
                mockito     : "org.mockito:mockito-all:$mockitoVersion",
                easymock    : "org.easymock:easymock:3.4",
                jmock       : "org.jmock:jmock:2.8.2",
                hamcrestCore: "org.hamcrest:hamcrest-core:1.3",
                hamcrestLib : "org.hamcrest:hamcrest-library:1.3"
        ]

        log = [
                slf4jApi  : "org.slf4j:slf4j-api:$slf4jVersion",
                slf4jJcl  : "org.slf4j:jcl-over-slf4j:$slf4jVersion",
                logback   : "ch.qos.logback:logback-classic:$logbackVersion",
                slf4jLog4j: "org.slf4j:log4j-over-slf4j:$slf4jVersion"
        ]

        misc = [
                h2                : "com.h2database:h2:$h2Version",
                joda              : "joda-time:joda-time:$jodaVersion",
                jstl              : "javax.servlet:jstl:1.2",
                javaxEl           : "javax.el:javax.el-api:3.0.0",
                poi               : "org.apache.poi:poi:$poiVersion",
                jacksonCore       : "com.fasterxml.jackson.core:jackson-core:$jacksonVersion",
                jacksonDatabind   : "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
                jacksonAnnotations: "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion",
                portlet           : "javax.portlet:portlet-api:2.0",
                standard          : "taglibs:standard:1.1.2",
                servlet           : "javax.servlet:javax.servlet-api:3.1.0",
                liferayService    : "com.liferay.portal:portal-services:6.2.2",
                commons           : "org.apache.commons:commons-lang3:3.4",
                ojdbc             : "com.github.noraui:ojdbc7:12.1.0.2",
                javax_inject      : "javax.inject:javax.inject:1",
                aspectjweaver     : "org.aspectj:aspectjweaver:$aspectjVersion",
                aspectjrt         : "org.aspectj:aspectjrt:$aspectjVersion",
                cglib             : "cglib:cglib:3.2.2",
                hikari            : "com.zaxxer:HikariCP:2.4.7",
                hessian           : "com.caucho:hessian:$hessianVersion",
                burlap            : "com.caucho:burlap:$burlapVersion",
                mq                : "org.apache.activemq:activemq-spring:$mqVersion",
                mqBroker          : "org.apache.activemq:activemq-broker:$mqVersion",
                wsdl4j            : "wsdl4j:wsdl4j:1.6.1",
                jaxb              : "com.sun.xml.bind:jaxb-xjc:2.2.4-1"
        ]

        hibernate = [
                validator: "org.hibernate:hibernate-validator:5.1.3.Final",
                ehcache  : "org.hibernate:hibernate-ehcache:$hibernateVersion",
                em       : "org.hibernate:hibernate-entitymanager:$hibernateVersion",
                core     : "org.hibernate:hibernate-core:$hibernateVersion"
        ]

        spring = [
                data           : "org.springframework.data:spring-data-jpa:$springJpaVersion",
                mongo          : "org.springframework.data:spring-data-mongodb:1.9.2.RELEASE",
                test           : "org.springframework:spring-test:$springVersion",
                webmvc         : "org.springframework:spring-webmvc:$springVersion",
                aop            : "org.springframework:spring-aop:$springVersion",
                jdbc           : "org.springframework:spring-jdbc:$springVersion",
                jms            : "org.springframework:spring-jms:$springVersion",
                orm            : "org.springframework:spring-orm:$springVersion",
                mvcPortlet     : "org.springframework:spring-webmvc-portlet:$springVersion",
                contextSupport : "org.springframework:spring-context-support:$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",
                hateoas        : "org.springframework.hateoas:spring-hateoas:0.17.0.RELEASE",
                plugin         : "org.springframework.plugin:spring-plugin-core:1.1.0.RELEASE"
        ]
    }
}

subprojects {
    apply plugin: 'java'
    sourceCompatibility = 1.8
    // Make sure transitive project dependencies are resolved
    configurations.compile.transitive = true

    configurations {
        all*.exclude group: "commons-logging", module: "commons-logging"
    }

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

    dependencies {
        compile log.slf4jApi, log.slf4jJcl, log.logback, log.slf4jLog4j
        testCompile tests.mockito, tests.junit
    }
}

task allCompile {
    doLast {
        description 'Task used to compile all modules in the project without running tests'
        subprojects.each { p ->
            p.getTasksByName("clean", true).each { t ->
                println "-> $p.name [CLEAN]"
                t.execute()
            }
            p.getTasksByName("compileJava", true).each { t ->
                println "-> $p.name [COMPILE]"
                t.execute()
            }
            p.getTasksByName("classes", true).each { t ->
                println "-> $p.name [CLASSES]"
                t.execute()
            }
            p.getTasksByName("jar", true).each { t ->
                println "-> $p.name [JAR]"
                t.execute()
            }
        }
    }
}


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
            }
        }
    }
}

wrapper {
    gradleVersion = '6.8.2'
}
