description = "FormKiQ Core - API Key Authorizer"

apply plugin: 'distribution'

def moduleName = "formkiq-module-lambda-authorizer-apikey"

dependencies {

	annotationProcessor group: 'com.formkiq', name: 'graalvm-annotations-processor', version: '1.4.2'
	
	implementation project(':aws-dynamodb')
	implementation project(':dynamodb-documents')
	implementation project(':fkq-lambda-services')
	
	implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17'
	implementation group: 'com.amazonaws', name: 'aws-lambda-java-core', version: '1.2.3'
	implementation group: 'com.google.code.gson', name: 'gson', version: '2.13.0'

    implementation group: 'com.formkiq', name: 'lambda-runtime-graalvm', version:'2.5.0'
    implementation group: 'com.formkiq', name: 'graalvm-annotations', version: '1.2.0'
	
	testImplementation project(':fkq-test-utils')

	testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.4'
    testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.6'
	testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.6'
}

compileJava {
    options.annotationProcessorPath += configurations.runtimeClasspath
}

nativeImage {
	outputFileName = "server"
	mainClassName = "com.formkiq.lambda.runtime.graalvm.LambdaRuntime"
	dockerImage = "ghcr.io/graalvm/graalvm-ce:ol9-java17-22.3.3"
    enableHttp = true
    enableHttps = true
    enableStatic = true
	systemProperty = ["java.net.preferIPv4Stack=true"]
}

test {
  failFast = true
  useJUnitPlatform()
}

/*
task buildZip(type: Zip) {
	dependsOn test, graalvmNativeImage
	inputs.files("${project.projectDir}/runtime/bootstrap", "${buildDir}/graalvm/server")
  	outputs.file("${buildDir}/${moduleName}.zip")
    
	archiveFileName = "${moduleName}.zip"
    destinationDirectory = file("${buildDir}")
    from("${project.projectDir}/runtime") {
        include 'bootstrap'
    }
    from("${buildDir}/graalvm") {
        include 'server'
    }
}*/
/*
task buildJava11Zip(type: Zip) {
    from compileJava
    into('lib') {
        from configurations.default
    }           
}*/

//task buildDeploy {
//	dependsOn assembleTemplate
//}

distZip.dependsOn graalvmNativeImage

tasks.distTar.enabled = false

distZip {
    archiveFileName = "api/${moduleName}.zip"
}

distributions {
    main {
        contents {
            from("runtime/") {
            	include "bootstrap"
            }
            from ("${buildDir}/graalvm") {
                include("server")
            }
            into '/'
        }
    }
}