plugins {
	id 'java-library'
    id 'eclipse'
	id 'eclipse-wtp'
    id 'idea'
    id 'war'
	id 'com.diffplug.eclipse.apt' version '3.41.1'
	id 'project-report'
    id 'checkstyle'
}

group 'com.eactive'
version '4.5.7'

def springVersion = "5.3.27"
def quartzVersion = "2.2.1"
def queryDslVersion = "5.0.0"
def hibernateVersion = "5.6.15.Final"

/*def nexusUrl = "https://nexus.eactive.synology.me:8090"*/
//def useOnJboss = false

def generatedJavaDir = "$buildDir/generated/java"

/*repositories {
    maven { 
		url "${nexusUrl}/repository/maven-public/" 
		allowInsecureProtocol = true
	}
}*/

project.webAppDirName = 'WebContent'

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

checkstyle {
    toolVersion = '8.45.1'
}
   
compileJava {
	options.encoding = 'UTF-8'
	options.compilerArgs = ['-parameters']
	sourceSets.main.java { srcDir generatedJavaDir }
	options.generatedSourceOutputDirectory = project.file(generatedJavaDir)

	aptOptions {
		processorArgs = [ 'querydsl.generatedAnnotationClass' : 'com.querydsl.core.annotations.Generated' ]
	}
}

war {
	def profile = project.findProperty("profile") ?: "tomcat"
	
	if (profile == "weblogic") {
		webXml = file("WebContent/WEB-INF/weblogic-web.xml")
		exclude 'WEB-INF/web.xml'
	}
	
	
	// rootSpec.exclude '**/persistence.xml'
	exclude '**/context.xml'
	archiveFileName = "eapim-admin.war"
	duplicatesStrategy = DuplicatesStrategy.WARN
}


tasks.withType(JavaCompile) {
	options.encoding = 'UTF-8'
	options.compilerArgs = ['-parameters']
}


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')
    implementation project(':elink-online-common')
	implementation project(':elink-online-emsclient')
	implementation project(':elink-portal-common')
	implementation project(':kjb-safedb')
    implementation project(":eapim-admin-kjb")

    /* Custom Libs */
    implementation fileTree(dir: 'libs', include: ['*.jar'])

	//implementation "org.dom4j:dom4j:2.1.3"
    //implementation "com.rabbitmq:amqp-client:3.6.6"

    implementation "commons-primitives:commons-primitives:1.0"
    implementation 'org.apache.commons:commons-lang3:3.12.0'
    implementation "commons-lang:commons-lang:2.6"
    implementation "commons-httpclient:commons-httpclient:3.1"
    implementation "commons-cli:commons-cli:1.1"
    implementation "commons-pool:commons-pool:1.6"
    implementation group: 'commons-io', name: 'commons-io', version: '2.6'
    implementation 'net.sf.j8583:j8583:1.18.0'
    implementation "commons-beanutils:commons-beanutils:1.6.1"
    implementation 'org.apache.commons:commons-compress:1.26.0'
//    implementation "log4j:log4j:1.2.17"

    implementation "net.sf.ehcache:ehcache:2.10.5"
    implementation "org.apache.poi:poi:3.2-FINAL"

    implementation 'org.codehaus.groovy:groovy:3.0.18'

    // https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
    compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
    
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.1'
    //implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: '2.13.1'
	implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.1'

    implementation "javax.jms:javax.jms-api:2.0"
    implementation "org.snmp4j:snmp4j:1.10.1"
    implementation "com.googlecode.json-simple:json-simple:1.1.1"

    implementation "io.netty:netty-all:4.1.0.Final"

    compileOnly "org.apache.mina:mina-filter-ssl:1.1.6"
    compileOnly "org.apache.mina:mina-core:1.1.6"

    // https://mvnrepository.com/artifact/org.modelmapper/modelmapper
    implementation 'org.modelmapper:modelmapper:2.4.5'

    ////implementation "xalan:xalan:2.6.0"
    implementation "com.sun.xml.messaging.saaj:saaj-impl:1.3.28"

    implementation "org.apache.ibatis:ibatis-sqlmap:2.3.4.726"
    implementation "org.jdom:jdom:1.1"
    implementation "com.google.code.gson:gson:2.3.1"
    implementation "javax.annotation:javax.annotation-api:1.2"
    implementation "net.sf.json-lib:json-lib-ext-spring:1.0.2"
    implementation "taglibs:standard:1.1.2"
    implementation "javax.servlet:jstl:1.1.2"
    implementation group: 'com.jcraft', name: 'jsch', version: '0.1.51'

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

    // https://mvnrepository.com/artifact/org.apache.poi/poi
    implementation group: 'org.apache.poi', name: 'poi', version: '3.17'
    // https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
    implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '3.17'

    implementation group: 'org.aspectj', name: 'aspectjrt', version: '1.9.7'
    implementation group: 'org.aspectj', name: 'aspectjtools', version: '1.9.7'

    implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
    implementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.15'
    implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.13'

    //implementation "com.eactive:ojdbc8:1.0"
    //implementation "com.eactive:INISAFECore:v2.2.28"
    //implementation "com.eactive:backport-util-concurrent:1.0"

    implementation "org.springframework:spring-web:${springVersion}"
    implementation "org.springframework:spring-aop:${springVersion}"
    implementation "org.springframework:spring-aspects:${springVersion}"
    implementation "org.springframework:spring-orm:${springVersion}"
    //implementation "com.eactive:spring-orm-ibatis-4.1.4:1.0"
    implementation "org.springframework:spring-webmvc:${springVersion}"
    implementation "org.springframework:spring-context:${springVersion}"
    implementation "org.springframework:spring-context-support:${springVersion}"
    implementation "org.springframework:spring-jdbc:${springVersion}"
    implementation 'org.springframework.data:spring-data-jpa:2.5.2'

    implementation 'org.hibernate:hibernate-entitymanager:5.4.33.Final'
    implementation 'org.hibernate:hibernate-validator:5.4.3.Final'
    implementation 'org.hibernate:hibernate-ehcache:5.4.3.Final'

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

    implementation 'ch.qos.logback:logback-classic:1.2.10'
    implementation 'ch.qos.logback:logback-access:1.2.10'
    implementation 'ch.qos.logback:logback-core:1.2.10'
	
	implementation files("libs/eai-bap-client.jar")
	
	compileOnly 'javax.xml.bind:jaxb-api:2.3.1'
	
	//implementation 'org.postgresql:postgresql:42.2.23'
	
	implementation 'backport-util-concurrent:backport-util-concurrent:3.0'
	
	implementation ('software.amazon.awssdk:s3:2.20.142') {
      exclude group: 'org.slf4j', module: 'slf4j-api'
      exclude group: 'org.slf4j', module: 'logback-classic'
   }
   implementation 'software.amazon.awssdk:sso:2.20.142'
   implementation 'software.amazon.awssdk:sts:2.20.142'
   
   implementation ('io.kubernetes:client-java:18.0.1') {
      exclude group: 'org.slf4j', module: 'slf4j-api'
      exclude group: 'org.slf4j', module: 'logback-classic'
   }
   
   implementation group: 'commons-net', name: 'commons-net', version: '3.5'

	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'
}

test {
    useJUnitPlatform()
}

configurations.all {
	exclude group: 'log4j', module: 'log4j'
	exclude group: 'org.apache.activemq'
	exclude group: 'org.codehaus.jackson'
    resolutionStrategy {
        // 10 minute cache of dynamic version navigation
        cacheDynamicVersionsFor 10, 'minutes'
        // Do not cache changing modules
        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 {
	wtp {
		component {
			contextPath = 'monitoring'
		}
	}
	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 {
		if (!natures.contains('org.eclipse.buildship.core.gradleprojectnature')) {
			natures.add('org.eclipse.buildship.core.gradleprojectnature')
			buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
		}
	}
}


tasks.withType(Checkstyle) {
    reports {
        xml.required = false
        html.required = true
    }
}