plugins {
    id 'java'
    id 'java-library'
    id 'eclipse-wtp'
    id 'idea'
}

group = 'com.eactive.ext.kjb'
version = '1.0-SNAPSHOT'

def springVersion = "5.3.27"


dependencies {
    annotationProcessor "org.projectlombok:lombok:1.18.28"

    api project(':elink-portal-common')
    api project(":kjb-safedb")

    api 'com.eactive.elink.common:elink-common-data:4.5.5'

    implementation fileTree(dir: "ext-libs", include: ["*.jar"])

//    api "org.springframework:spring-context:${springVersion}"
//    api "org.springframework:spring-webmvc:${springVersion}"
//    api "org.springframework.security.oauth:spring-security-oauth2:2.3.8.RELEASE"

    implementation "com.google.code.gson:gson:2.3.1"
    implementation "org.apache.httpcomponents.client5:httpclient5:5.1"


    compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'

    compileOnly 'org.slf4j:jul-to-slf4j:1.7.35'
    compileOnly 'org.slf4j:jcl-over-slf4j:1.7.35'
    compileOnly 'org.slf4j:log4j-over-slf4j:1.7.35'
    compileOnly 'org.slf4j:slf4j-api:1.7.35'

    compileOnly "org.jdom:jdom:1.1"

    compileOnly fileTree(dir: "ext-libs/compileOnly", include: ["*.jar"])


    testAnnotationProcessor "org.projectlombok:lombok:1.18.28"

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testImplementation 'ch.qos.logback:logback-classic:1.2.10'
    testImplementation 'ch.qos.logback:logback-access:1.2.10'
    testImplementation 'ch.qos.logback:logback-core:1.2.10'
    testImplementation 'org.slf4j:jul-to-slf4j:1.7.35'
    testImplementation 'org.slf4j:jcl-over-slf4j:1.7.35'
    testImplementation 'org.slf4j:log4j-over-slf4j:1.7.35'
    testImplementation 'org.slf4j:slf4j-api:1.7.35'

    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.8.2'
}


// Compile
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(8)
    }
}

compileJava {
    options.encoding = 'UTF-8'
}


// Build
task sourcesJar(type: Jar, dependsOn: classes) {
    archiveClassifier = 'sources'
    from sourceSets.main.allSource
}

artifacts {
    archives sourcesJar
}

jar {
    archiveFileName = "eapim-admin-kjb.jar"
}


// Test
test {
    useJUnitPlatform()

    systemProperty "kjb_safedb.mode", System.getProperty("kjb_safedb.mode")

    if (project.hasProperty("safedb")) {
        systemProperty "kjb_safedb.mode", "real"
        systemProperty "kjb_safedb.test.strict_mode", "true"

        classpath += files("/safedb/JavaAPI/config")
        classpath += fileTree(dir: "/safedb/JavaAPI/lib", include: ["*.jar"])
    }


    testLogging {
        events "PASSED", "FAILED", "SKIPPED", "STANDARD_OUT", "STANDARD_ERROR"
        exceptionFormat "full"
        showStandardStreams = true
    }
}



configurations.all {
    resolutionStrategy {
        // 동적 버전 탐색을 10분 캐시
        cacheDynamicVersionsFor 10, 'minutes'
        // 변하는 모듈(Changing Module)을 캐시하지 않음
        cacheChangingModulesFor 0, 'seconds'
    }
}

task settingEclipseEncoding {
    if (project.file('.settings').exists()) {
        File f = file('.settings/org.eclipse.core.resources.prefs')
        f.write('eclipse.preferences.version=1\n')
        f.append('encoding/<project>=utf-8')
    }
}

eclipse {
    synchronizationTasks settingEclipseEncoding
}