description = "FormKiQ Core - Console"

apply plugin: 'distribution'

sourceSets {
    integration {
        java.srcDir "$projectDir/src/integration/java"
        resources.srcDir "$projectDir/src/integration/resources"
        compileClasspath += main.output + test.output
        runtimeClasspath += main.output + test.output
    }
}

configurations {
    integrationImplementation.extendsFrom testImplementation
    integrationRuntime.extendsFrom testRuntime
}

dependencies {

	implementation project(':aws-s3')
	implementation project(':aws-ssm')

	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: 'org.json', name: 'json', version: '20250107'

	testImplementation project(':aws-cognito-identity')
	testImplementation project(':aws-cognito-identityprovider')
	testImplementation project(':fkq-test-utils')
  testImplementation project(':fkq-lambda-services')
	testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.13.0'
	testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17'

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

	testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.6'
	testImplementation group: 'com.microsoft.playwright', name: 'playwright', version: '1.51.0'
}

test {
  failFast = true
  useJUnitPlatform()
}

task integrationTest(type: Test) {
    testClassesDirs = sourceSets.integration.output.classesDirs
    classpath = sourceSets.integration.runtimeClasspath
    useJUnitPlatform()
}

task buildTemplate {
	inputs.files("src/main/resources/cloudformation/template.yaml", "src/main/resources/cloudformation/template-install.yaml", "src/main/resources/cloudformation/template-users.yaml")
	outputs.files("${buildDir}/distributions/console/template.yaml", "${buildDir}/distributions/console/template-install.yaml", "${buildDir}/distributions/console/template-users.yaml")

	doLast {
		copy {
		  from layout.buildDirectory.dir("${buildDir}/../src/main/resources/cloudformation")
		  include "template*"
	      into "${buildDir}/distributions/console"
	    }
	}
}

distZip.dependsOn buildTemplate

tasks.distTar.enabled = false

distZip {
    archiveFileName = "console/console-installer.zip"
}

distributions {
    main {
        contents {
            from compileJava
    		from processResources
    		into('lib') {
        		from configurations.runtimeClasspath
    		}
            into '/'
        }
    }
}
