plugins {
	id 'java-library'
	id 'maven-publish'
	id 'eclipse-wtp'
	id 'idea'
	id 'com.diffplug.eclipse.apt' version '3.41.1'
}
group 'com.eactive'
version '4.5.1-SNAPSHOT'

def springVersion = "5.3.27"
def quartzVersion = "2.3.2"
def undertowVersion = "1.4.28.Final"
def queryDslVersion = "5.0.0"
def hibernateVersion = "5.6.15.Final"

def generatedJavaDir = "$buildDir/generated/java"
def nexusUrl = "https://nexus.eactive.synology.me:8090"

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

compileJava {
	options.encoding = 'UTF-8'
    sourceSets.main.java { srcDir generatedJavaDir }
	options.generatedSourceOutputDirectory = project.file(generatedJavaDir)
	
	aptOptions {
		processorArgs = [ 'querydsl.generatedAnnotationClass' : 'com.querydsl.core.annotations.Generated' ]
	}
}

jar {
	exclude '**/persistence.xml'
}

tasks.withType(JavaCompile) {
	options.encoding = 'UTF-8'
}

dependencies {

	annotationProcessor "org.projectlombok:lombok:1.18.28", "org.projectlombok:lombok-mapstruct-binding:0.2.0", "org.mapstruct:mapstruct-processor:1.5.5.Final"
	annotationProcessor "com.querydsl:querydsl-apt:${queryDslVersion}:jpa", "jakarta.persistence:jakarta.persistence-api:2.2.3", "jakarta.annotation:jakarta.annotation-api:1.3.5"
	
    //implementation project(':elink-online-core')
    //implementation project(':elink-online-transformer')
    api project(':elink-online-transformer')
    
    compileOnly fileTree(dir: 'libs', include: ['*.jar'])
	
	api (group: 'org.apache.activemq', name: 'activemq-console', version: '5.14.5'){
		exclude group: 'com.fasterxml.jackson.core'
	}
	api group: 'org.apache.activemq', name: 'activemq-spring', version: '5.14.5'
	
    api 'backport-util-concurrent:backport-util-concurrent:3.0'
	
    api 'com.github.vladimir-bukhtoyarov:bucket4j-jcache:6.0.2'
    api 'io.github.resilience4j:resilience4j-core:1.7.1'
    api 'io.github.resilience4j:resilience4j-circuitbreaker:1.7.1'
    api 'io.github.resilience4j:resilience4j-micrometer:1.7.1'
    api 'io.micrometer:micrometer-core:1.5.17'
    api 'io.micrometer:micrometer-registry-prometheus:1.5.17'

    //api "com.eactive:mina-core-1.0.10-custom:1.0:custom@jar"
    api ("org.apache.mina:mina-filter-ssl:1.0.10") {
        exclude module: 'mina-core'
    }

    api group: 'commons-fileupload', name: 'commons-fileupload', version: '1.5'

    api 'org.snmp4j:snmp4j:1.9.1f'
	api group: 'com.lmax', name: 'disruptor', version: '3.4.4'
    api group: 'commons-httpclient', name: 'commons-httpclient', version: '3.1'
//    api group: 'log4j', name: 'log4j', version: '1.2.17'
	
    api 'com.nimbusds:nimbus-jose-jwt:9.24.3'

    api "io.undertow:undertow-servlet:${undertowVersion}"
    api 'org.java-websocket:Java-WebSocket:1.3.9'
    api 'javax.cache:cache-api:1.1.1'

    api 'org.apache.ignite:ignite-slf4j:2.14.0'
    api 'org.apache.ignite:ignite-kubernetes:2.14.0'
    // ignite 2.17 - JDK 11 이상 필요
//    api 'org.apache.ignite:ignite-slf4j:2.17.0'
//    api 'org.apache.ignite:ignite-kubernetes:2.17.0'

    //api 'com.eactive:xc3:1.0'
    //api 'com.eactive:xc2:1.0'
    //api 'com.eactive:INICrypto:v4.1.22'
    //api 'com.eactive:INISAFECore:v2.2.28'
    //api 'com.eactive:INISAFENet:v7.2.51_NS'
    //api 'com.eactive:INISAFEPKI:v1.1.33'

	//api 'com.eactive:Egloan_aes:1.0'
    //api 'com.eactive:ExafeiE2E:1.0'
    //api 'com.eactive:tcseed:1.0'
    //api "com.eactive:backport-util-concurrent:1.0"

    api "org.quartz-scheduler:quartz:${quartzVersion}"

    api group: 'commons-cli', name: 'commons-cli', version: '1.1'
    api "org.springframework:spring-web:${springVersion}"
    api "org.springframework:spring-jms:${springVersion}"
    api "org.springframework.security.oauth:spring-security-oauth2:2.3.8.RELEASE"

    api 'org.yaml:snakeyaml:1.30'
    implementation 'org.codehaus.groovy:groovy:3.0.18'

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

    //compileOnly "tmax:webt:7.0.2.0-r11661-forJEUS8.0"
    //compileOnly "tmax:webtasync:2.0.3.1-r11801-forJEUS8.1"
    //compileOnly "tmax:jeus:1.0"

    api 'org.apache.httpcomponents.client5:httpclient5:5.1'
    api 'org.apache.httpcomponents.core5:httpcore5:5.1'
	
    compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
    compileOnly group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version: '2.3.3'
    compileOnly 'javax.resource:javax.resource-api:1.7'
    compileOnly 'javax.jms:javax.jms-api:2.0.1'
    
    compileOnly group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: '2.13.1'

	testRuntimeOnly 'com.h2database:h2:2.1.214'
	testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
	testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
	testImplementation 'org.springframework.boot:spring-boot-starter-test:2.6.15'
	testImplementation 'junit:junit:4.4'
}

test {
    useJUnitPlatform()
}

publishing {
    repositories {
        maven {
            name = 'eactiveRepository'
            def releasesRepoUrl = "${nexusUrl}/repository/maven-releases/"
            def snapshotsRepoUrl = "${nexusUrl}/repository/maven-snapshots/"
            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
            credentials(PasswordCredentials)
        }
    }

	publications {
		mavenJava(MavenPublication) {
			from components.java
			pom {
				description = "eLink common module"
				licenses {
					license {
						name = "Commercial License"
						url = "http://eactive.co.kr"
					}
				}
			}
		}
	}
}

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

artifacts {
    archives sourcesJar
}

configurations.all {
	exclude group: 'org.apache.geronimo.specs', module: 'geronimo-jta_1.0.1B_spec'
//	exclude group: 'javax.transaction', module: 'javax.transaction-api'
	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')
    }
}

task initDirs() {
	file(generatedJavaDir).mkdirs()
}

eclipse {
    synchronizationTasks settingEclipseEncoding, initDirs
	jdt {
    	apt {
    	    // generated 된 패스 경로를 .setting/org.eclipse.jdt.apt.core.prefs 의 org.eclipse.jdt.apt.genSrcDir에 적용한다.
    	    // project > properties > Java Compiler > Annoation Processing 화면에서 확인 가능하다.
    		genSrcDir = file(generatedJavaDir)
    	}
    }
	project {
		natures = ['org.eclipse.buildship.core.gradleprojectnature',
			'org.eclipse.jdt.core.javanature',
			'org.eclipse.wst.common.project.facet.core.nature',
			'org.eclipse.wst.common.modulecore.ModuleCoreNature',
			'org.eclipse.jem.workbench.JavaEMFNature']
		buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
		buildCommand 'org.eclipse.wst.validation.validationbuilder'
		buildCommand 'org.eclipse.wst.common.project.facet.core.builder'
		buildCommand 'org.eclipse.jdt.core.javabuilder'
	}
}
