plugins {
    id 'java'
    id 'org.springframework.boot' version '3.3.5'
    id 'io.spring.dependency-management' version '1.1.6'
}

group = 'com.xuyi'
version = '1.0.0'

java {
    sourceCompatibility = '17'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    // Spring Boot Starters
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-cache'
    implementation 'org.springframework.boot:spring-boot-starter-mail'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    
    // Database
    runtimeOnly 'com.mysql:mysql-connector-j'
    implementation 'com.zaxxer:HikariCP'
    
    // Redis Cache - REMOVED
    // implementation 'org.springframework.boot:spring-boot-starter-data-redis'
    
    // JWT
    implementation 'io.jsonwebtoken:jjwt-api:0.12.3'
    runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3'
    runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3'
    
    // Markdown processing
    implementation 'com.vladsch.flexmark:flexmark-all:0.64.8'
    
    // RSS generation
    implementation 'com.rometools:rome:2.1.0'
    
    // API Documentation
    implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
    
    // Utilities
    implementation 'org.apache.commons:commons-lang3:3.13.0'
    implementation 'commons-io:commons-io:2.15.0'
    
    // Lombok
    compileOnly 'org.projectlombok:lombok:1.18.30'
    annotationProcessor 'org.projectlombok:lombok:1.18.30'
    
    // Test dependencies
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.springframework.security:spring-security-test'
    testImplementation 'org.testcontainers:junit-jupiter'
    testImplementation 'org.testcontainers:mysql'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

dependencyManagement {
    imports {
        mavenBom "org.testcontainers:testcontainers-bom:1.19.3"
    }
}

tasks.named('test') {
    useJUnitPlatform()
}

// Performance optimization for build
tasks.withType(JavaCompile) {
    options.compilerArgs += ['-Xlint:unchecked', '-Xlint:deprecation']
    options.encoding = 'UTF-8'
}

// JAR optimization
jar {
    enabled = false
    archiveClassifier = ''
}

bootJar {
    enabled = true
    archiveClassifier = ''
    layered {
        enabled = true
    }
}
