plugins {
    java
    id("org.springframework.boot") version "3.4.4"
    id("io.spring.dependency-management") version "1.1.7"
//    id("com.github.johnrengelman.shadow") version "8.1.1"
}

group = "com.alttd.altitudeweb"
version = "0.0.1-SNAPSHOT"

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

configurations {
    compileOnly {
        extendsFrom(configurations.annotationProcessor.get())
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(project(":open_api"))
    implementation(project(":database"))
    implementation("org.springframework.boot:spring-boot-starter-web")
    annotationProcessor("org.projectlombok:lombok")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    implementation("com.mysql:mysql-connector-j:8.0.32")
    implementation("org.mybatis:mybatis:3.5.13")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
    implementation("org.springframework.boot:spring-boot-configuration-processor")
    implementation("org.springframework.boot:spring-boot-starter-hateoas")
}

tasks.withType<Test> {
    useJUnitPlatform()
}

tasks.bootJar {
    mainClass.set("com.alttd.altitudeweb.AltitudeWebApplication")
    archiveBaseName.set("altitudeweb")
    archiveClassifier.set("")
}


//tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
//    mergeServiceFiles()
//    dependencies {
//        include(dependency("com.mysql:mysql-connector-j"))
//    }
//}

//tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
//    manifest {
//        attributes["Main-Class"] = "com.alttd.altitudeweb.AltitudeWebApplication"
//    }
//    archiveBaseName.set("altitudeweb")
//    archiveClassifier.set("")
//    mergeServiceFiles()
//
//    // Include everything
//    from(sourceSets.main.get().output)
//
//    // Include all project dependencies
//    configurations = listOf(project.configurations.runtimeClasspath.get())
//
//    // Ensure MySQL is included (even though it should be part of runtimeClasspath already)
//    dependencies {
//        include(dependency("com.mysql:mysql-connector-j"))
//    }
//
//    // Enable zip64 mode for large JARs
//    isZip64 = true
//}
//
//// Make the shadowJar task the default jar task
//tasks.named("jar") {
//    enabled = false
//}
//
//tasks.named("assemble") {
//    dependsOn("shadowJar")
//}
