plugins {
	id 'org.springframework.boot' version '3.0.6'
	id 'io.spring.dependency-management' version '1.1.0'
	id 'org.graalvm.buildtools.native' version '0.9.20'
	id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
	maven { url 'https://repo.spring.io/milestone' }
	mavenCentral()
	maven { url 'https://repo.spring.io/snapshot' }
}

ext {
	set('springCloudVersion', "2022.0.2")
	set('testcontainersVersion', "1.18.0")
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'org.flywaydb:flyway-core'
	implementation 'org.springframework.cloud:spring-cloud-function-web'
	runtimeOnly 'com.h2database:h2'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation 'org.testcontainers:junit-jupiter'
}

dependencyManagement {
	imports {
		mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
		mavenBom "org.testcontainers:testcontainers-bom:${testcontainersVersion}"
	}
}

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

//tasks.named('bootBuildImage') {
//	if (!project.hasProperty('native')) {
//		builder = 'paketobuildpacks/builder:tiny'
//		environment = ['BP_NATIVE_IMAGE': 'false',
//						'BP_BINARY_COMPRESSION_METHOD':'upx',
//						'USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM':'false'
//						]
//	} else {
//		buildpacks =  ['gcr.io/paketo-buildpacks/bellsoft-liberica:9.9.0-ea', 'gcr.io/paketo-buildpacks/java-native-image']
//	}
//
//}

tasks.named('bootBuildImage') {
	if (!project.hasProperty('native')) {
		builder = 'paketobuildpacks/builder:tiny'
		environment = ['BP_NATIVE_IMAGE': 'false']
	} else {
		if(project.hasProperty('x86')){
			buildpacks =  ['gcr.io/paketo-buildpacks/bellsoft-liberica:9.9.0-ea', 'gcr.io/paketo-buildpacks/java-native-image']
		} else {
			if(project.hasProperty('aarm')) {
				builder = 'dashaun/java-native-builder-arm64'
			}
		}
	}
}
