plugins {
    id 'java'
    id 'org.springframework.boot' version '3.4.0'
    id 'io.spring.dependency-management' version '1.1.6'
    id 'org.hibernate.orm' version '6.6.2.Final'
}

ext {
    hutoolVersion = "5.8.32"
}

allprojects {
    apply plugin: 'java'

    group = 'com.sikey.wa04'
    version = '1.0.1'

    ext {
        set('springCloudVersion', "2024.0.0")
        hutoolVersion = "5.8.32"
        gvavaVersion = "33.3.1-jre"
    }

    repositories {
        maven { url 'https://maven.aliyun.com/repository/public' }
        mavenCentral()
    }

    hibernate {
        enhancement {
            enableAssociationManagement = true
        }
    }

    test {
        useJUnitPlatform()
    }

    configurations {
        compileOnly {
            extendsFrom annotationProcessor
        }
    }

    java {
        toolchain {
            languageVersion = JavaLanguageVersion.of(23)
        }
    }

    task printVersion {
        doLast {
            println "Project: ${project.name}, springCloudVersion: ${springCloudVersion}, hutoolVersion: ${hutoolVersion}"
        }
    }
}

subprojects { Project project ->
    apply plugin: 'io.spring.dependency-management'

    if (project.name != 'app-gateway') {
        dependencies {
            implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
            implementation 'org.springframework.boot:spring-boot-starter-data-redis'
            implementation 'org.springframework.boot:spring-boot-starter-amqp'
        }
    }

    dependencies {
        implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
        implementation 'org.springframework.boot:spring-boot-starter-validation'
        implementation 'org.springframework.boot:spring-boot-starter-actuator'
        implementation 'org.springframework.boot:spring-boot-starter-websocket'

        // https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
        implementation 'com.squareup.okhttp3:okhttp:4.12.0'
        // https://mvnrepository.com/artifact/com.eatthepath/pushy
        implementation 'com.eatthepath:pushy:0.15.4'
        implementation "cn.hutool:hutool-all:${hutoolVersion}"
        // https://mvnrepository.com/artifact/org.gavaghan/geodesy
        implementation "org.gavaghan:geodesy:1.1.3"

        // aliyun oso sdk
        implementation 'com.aliyun.oss:aliyun-sdk-oss:3.17.4'
        implementation 'javax.activation:activation:1.1.1'
        implementation 'javax.xml.bind:jaxb-api:2.3.1'
        implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.3'

        runtimeOnly 'com.mysql:mysql-connector-j'

        testImplementation 'org.springframework.amqp:spring-rabbit-test'
        testImplementation 'org.springframework.security:spring-security-test'

        compileOnly 'org.projectlombok:lombok'
        annotationProcessor 'org.projectlombok:lombok'
        annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
        testImplementation 'org.springframework.boot:spring-boot-starter-test'
        testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

        implementation 'org.mapstruct:mapstruct:1.5.5.Final'
        annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'
    }

    dependencyManagement {
        imports {
            mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
        }
    }
}