plugins {
	id 'java'
	id 'war'
	id 'org.springframework.boot' version '3.4.5' apply false
	id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.bsmlab.dfx'
version = '0.1'

// git commit hash -> application.yml
def gitCommitId = ''
try {
    def stdout = new ByteArrayOutputStream()
    providers.exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        standardOutput = stdout;
    }.result.get()
    gitCommitId = stdout.toString().trim()
}
catch (Exception ignored) {
    print "git commit ID is not available."
}

// gradle project properties -> application.yml
processResources {
    filesMatching('**/application.yml') {
        expand(project.properties + [
                commitId: gitCommitId, version: version,
                user: [home: System.getProperty('user.home')]
        ])
    }
}

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

repositories {
	mavenCentral()
}

apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'

bootWar {
	enabled = true
}

bootJar {
	enabled = false
}

dependencies {
	providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
	implementation 'org.springframework.boot:spring-boot-starter-jdbc'
	implementation 'org.springframework.boot:spring-boot-starter-security'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.4'
	implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16'
	implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
    implementation 'org.bouncycastle:bcprov-jdk18on:1.83'
	runtimeOnly 'com.ibm.db2:jcc'
	runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
	runtimeOnly 'com.mysql:mysql-connector-j'
	runtimeOnly 'com.oracle.database.jdbc:ojdbc11'
	runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
	runtimeOnly 'org.postgresql:postgresql'
	compileOnly 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.4'
	testImplementation 'org.springframework.security:spring-security-test'
	testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
	annotationProcessor 'org.projectlombok:lombok'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
}

tasks.named('test') {
	useJUnitPlatform()
}
