import com.github.jk1.license.render.*
import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter
import com.github.jk1.license.filter.LicenseBundleNormalizer

plugins {
	kotlin("jvm") version "1.9.25"
	kotlin("plugin.spring") version "1.9.25"
	id("org.springframework.boot") version "3.3.4"
	id("io.spring.dependency-management") version "1.1.6"
	id("com.github.jk1.dependency-license-report") version "2.0"
}

group = "kr.lunaticbum.back"
version = "0.0.7-SNAPSHOT"

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

configurations {
	compileOnly {
		extendsFrom(configurations.annotationProcessor.get())
	}
}

repositories {
	mavenCentral()

	maven { url = uri("https://repo.spring.io/milestone") }

}

dependencies {
//	implementation ("jakarta.servlet:jakarta.servlet-api") //스프링부트 3.0 이상
//	implementation ("jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api") //스프링부트 3.0 이상
//	implementation ("org.glassfish.web:jakarta.servlet.jsp.jstl") //스프링부트 3.0 이상
	implementation ("org.slf4j:jcl-over-slf4j")
//	implementation ("org.springframework.boot:spring-boot-starter-batch")
	implementation ("org.springframework.boot:spring-boot-starter-quartz")

	implementation ("com.google.code.gson:gson:2.11.0")
	implementation ("org.apache.tomcat.embed:tomcat-embed-jasper")
	implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
	implementation("org.springframework.boot:spring-boot-starter-web")
	implementation("org.springframework.boot:spring-boot-starter-webflux")
	implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
	implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
	implementation("org.jetbrains.kotlin:kotlin-reflect")
	implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
	implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
	implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity6")

	implementation("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
	implementation ("org.jsoup:jsoup:1.18.1")

	implementation ("org.seleniumhq.selenium:selenium-java:4.10.0")

	implementation ("org.commonmark:commonmark:0.18.0")
	implementation ("net.coobird:thumbnailator:0.4.14")


	implementation ("com.drewnoakes:metadata-extractor:2.19.0")
	implementation("org.springframework.boot:spring-boot-starter-security")
	compileOnly("org.projectlombok:lombok")

//	implementation(platform("com.google.cloud:libraries-bom:  26.55.0"))
//	implementation("com.google.cloud:google-cloud-apikeys")
	implementation ("com.google.maps:google-maps-services:2.2.0")
//	implementation ("org.springframework.ai:spring-ai-openai-spring-boot-starter:1.0.0-SNAPSHOT")
//	implementation ("org.springframework.ai:spring-ai-vertex-ai-gemini-spring-boot-starter:1.0.0-SNAPSHOT")
//	implementation("org.springframework.ai:spring-ai-ollama-spring-boot-starter:1.0.0-SNAPSHOT")
	implementation(platform("org.springframework.ai:spring-ai-bom:1.0.0-M6"))
	implementation("org.springframework.ai:spring-ai-ollama-spring-boot-starter:1.0.0-M6")
	implementation ("org.springframework.ai:spring-ai-qdrant-store-spring-boot-starter")
//	implementation ("io.qdrant:client:1.13.0")

	implementation ("org.slf4j:slf4j-simple:1.7.25")

	implementation("io.jsonwebtoken:jjwt-api:0.11.5")
	implementation("io.jsonwebtoken:jjwt-impl:0.11.5")
	implementation("io.jsonwebtoken:jjwt-jackson:0.11.5")

	annotationProcessor("org.projectlombok:lombok")
	testImplementation("org.springframework.boot:spring-boot-starter-test")
	testImplementation("io.projectreactor:reactor-test")
	testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
	testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}


kotlin {
	compilerOptions {
		freeCompilerArgs.addAll("-Xjsr305=strict")
	}
}
tasks.withType<org.gradle.jvm.tasks.Jar>() {
	duplicatesStrategy = DuplicatesStrategy.EXCLUDE
	exclude("META-INF/BC1024KE.RSA", "META-INF/BC1024KE.SF", "META-INF/BC1024KE.DSA")
	exclude("META-INF/BC2048KE.RSA", "META-INF/BC2048KE.SF", "META-INF/BC2048KE.DSA")
}
tasks.withType<Test> {
	useJUnitPlatform()
}


tasks.jar {
	archiveFileName.set("app.jar")
	manifest {
		attributes["Main-Class"] = "kr.lunaticbum.back.lun.LunApplicationKt"
	}
	configurations["compileClasspath"].forEach { file: File ->
		from(zipTree(file.absoluteFile))
	}
	duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.jar {

	// Otherwise you'll get a "No main manifest attribute" error
	manifest {
		attributes["Main-Class"] = "kr.lunaticbum.back.lun.LunApplicationKt"
	}

	// To avoid the duplicate handling strategy error
	duplicatesStrategy = DuplicatesStrategy.EXCLUDE

	// To add all of the dependencies otherwise a "NoClassDefFoundError" error
	from(sourceSets.main.get().output)

	dependsOn(configurations.runtimeClasspath)
	from({
		configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
	})
}


licenseReport {
	// 라이센스 고지 파일을 반환할 경로 default는 $projectDir/reports/dependency-license
	outputDir = "$projectDir/build/licenses"

	// markdown 생성
//	renderers = listOf(InventoryMarkdownReportRenderer()).toTypedArray()

	// html 생성
	 renderers = listOf(InventoryHtmlReportRenderer()).toTypedArray()

	// xml 생성
	// renderers = [new XmlReportRenderer()]

	// 보고서에 첫 번째 수준 종속성만 표기
	filters = listOf(LicenseBundleNormalizer(),  ExcludeTransitiveDependenciesFilter()).toTypedArray()
}