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

group 'com.eactvie'
//version '4.5.7'

def springVersion = "5.3.27"
//def springSecurityVersion = '4.2.13.RELEASE'
def springSecurityVersion = '5.7.11'
def springOauth2Version = '2.3.8.RELEASE'
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"
//
//repositories {
//    maven {
//		url "${nexusUrl}/repository/maven-public/"
//		allowInsecureProtocol = true
//	}
//}

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

war {
	// 2025.10.13 - weblogic 대응 (weblogic-web.xml -> web.xml 강제 사용)
	def profile = project.findProperty("profile") ?: "tomcat"
	
	if (profile == "weblogic") {
		webXml = file("WebContent/WEB-INF/weblogic-web.xml")
		exclude 'WEB-INF/web.xml'
	}
	archiveFileName = "eapim-online.war"
	duplicatesStrategy = DuplicatesStrategy.WARN

	exclude '**/persistence.xml'
	exclude '**/context.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 ('com.eactive:elink-online-core:4.5-SNAPSHOT') { changing = true }
//        implementation ('com.eactive:elink-online-transformer:4.5-SNAPSHOT') { changing = true }
//        implementation ('com.eactive:elink-online-common:4.5-SNAPSHOT') { changing = true }
//        implementation ('com.eactive:elink-online-emsclient:4.5-SNAPSHOT') { changing = true }
		implementation project(':elink-online-core')
		implementation project(':elink-online-transformer')
		implementation project(':elink-online-common')
		implementation project(':elink-online-emsclient')
        
		implementation fileTree(dir: 'libs', include: ['*.jar'])

//        implementation 'org.xerial:sqlite-jdbc:3.39.2.1'

		/*
		mina-filter-ssl에 Exclude 설정을 하였으나
		mina-integration-spring에서도 mina-filter-ssl을 참조하여
		해당 "mina-filter-ssl" 참조관계로 인해 ".apache.mina:mina-core:1.0.10"가 참조되는 일이 발생하여
		두 라이브러르 모두 "exclude group" 설정을 추가함
		아래의 configurations 처럼 ALL로 제거하여도 무방함 참고
		configurations {
			all*.exclude group: 'org.apache.mina', module:'mina-core'
		}
			*/
		implementation ("org.apache.mina:mina-filter-ssl:1.0.10"){
				exclude group: 'org.apache.mina'
		}
		implementation ('org.apache.mina:mina-integration-spring:1.0.10'){
				exclude group: 'org.apache.mina'
		}

		//implementation 'com.eactive:java_websocket-custom:1.0'
		
		//implementation "tmax:webt:7.0.2.0-r11661-forJEUS8.0"
		//implementation "tmax:webtasync:2.0.3.1-r11801-forJEUS8.1"

		implementation 'org.graylog2:gelfj:1.1.16'


		implementation "org.springframework:spring-webmvc:${springVersion}"
		implementation "org.springframework.security:spring-security-jwt:1.1.1.RELEASE"

		//implementation "com.eactive:ojdbc8:1.0"
		//implementation "org.postgresql:postgresql:42.2.23"
		implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.4'
		//implementation "com.oracle.ojdbc:ojdbc8:19.3.0.0"
		
		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 'co.elastic.logging:logback-ecs-encoder:1.5.0'
		
		implementation 'net.sf.j8583:j8583:1.18.0'
		runtimeOnly 'net.minidev:json-smart:2.4.11'

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

configurations.all {
	resolutionStrategy {
		force 'org.slf4j:slf4j-api:1.7.36' // slf4j-api를 강제로 1.7.36으로 고정
	}
}

project.webAppDirName = 'WebContent'

test {
    useJUnitPlatform()
}

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

configurations.all {
	exclude group: 'log4j', module: 'log4j'
	exclude group: 'org.codehaus.jackson'
}

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

//eclipseJdt.finalizedBy settingEclipseEncoding

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

eclipse {
	wtp {
		component {
			contextPath = '/'
		}
	}
    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'
	}
}

