import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "cc-lotus.gaf3"
version = rootProject.version

plugins {
    id("java-library")
    id("maven-publish")
    id("io.spring.dependency-management")
    kotlin("jvm")
    kotlin("plugin.spring")
    kotlin("plugin.jpa")
}

project(":shared") {
    tasks.jar {
        subprojects {
            from(tasks.withType<JavaCompile>())
            from(tasks.withType<KotlinCompile>())
        }
    }
//    tasks.sourcesJar {
//        subprojects {
//            from(sourceSets.main.get().allSource)
//        }
//    }
}

subprojects {
    apply(plugin = "java")
    apply(plugin = "maven-publish")
    apply(plugin = "io.spring.dependency-management")
    apply(plugin = "org.jetbrains.kotlin.jvm")
    apply(plugin = "org.jetbrains.kotlin.plugin.spring")
    apply(plugin = "org.jetbrains.kotlin.plugin.jpa")
    dependencies {
        api(platform(project(":platform")))
        implementation(kotlin("reflect"))
        implementation(kotlin("stdlib-jdk8"))
        implementation("org.bouncycastle:bcprov-jdk15on")
        implementation("org.bouncycastle:bcpkix-jdk15on")
        implementation("com.alibaba:fastjson")
        implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
        implementation("org.springframework.boot:spring-boot-starter-webflux")
        implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
        implementation("javax.validation:validation-api")
    }
    dependencyManagement {
        imports {
            mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
            mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
        }
    }
    tasks.named<Jar>("jar") {
        archiveBaseName.set("gaf3-core-${project.name}")
    }
}

project("cloud") {
    dependencies {
        implementation(project(path = ":shared:util"))
        implementation("io.github.openfeign:feign-jackson")
        annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
    }
}

publishing {
    publications {
        create<MavenPublication>("maven") {
            artifactId = "gaf-core-shared"
            from(components["java"])
            // artifact(tasks["sourcesJar"])
        }
    }
}

tasks.named<Jar>("jar") {
    archiveBaseName.set("gaf3-core-${project.name}")
}
