/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    id 'java'
    id 'application'
    id 'checkstyle'
}

checkstyle {
    toolVersion = '8.29'
    configFile = file('./checkstyle.xml')
    // Allow some warnings before putting checkstyle in place. These warnings will be gradually removed.
    maxWarnings = 43
}

repositories {
    mavenCentral()
}

application {
    mainClassName 'com.ilmlf.delivery.DeliveryApp'
}

dependencies {
    implementation 'software.amazon.awscdk:core:1.114.0'
    implementation 'software.amazon.awscdk:ec2:1.114.0'
    implementation 'software.amazon.awscdk:apigateway:1.114.0'
    implementation 'software.amazon.awscdk:lambda:1.114.0'
    implementation 'software.amazon.awscdk:rds:1.114.0'
    implementation 'software.amazon.awscdk:sns-subscriptions:1.114.0'
    implementation 'software.amazon.awscdk:cloudwatch-actions:1.114.0'
    implementation 'com.github.spullara.mustache.java:compiler:0.9.7'
    implementation 'com.googlecode.json-simple:json-simple:1.1.1'
    implementation 'io.github.json-snapshot:json-snapshot:1.0.17'
    implementation 'commons-codec:commons-codec:1.11'
    implementation 'software.amazon.awscdk:sam:1.102.0'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
    testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.7.1'
    testImplementation 'org.assertj:assertj-core:3.18.1'


    compileOnly 'org.projectlombok:lombok:1.18.20'
    annotationProcessor 'org.projectlombok:lombok:1.18.20'

    // Prevent using feature log4j below 2.16.0 which can contain CVE-2021-44228
    // See step 3 in https://blog.gradle.org/log4j-vulnerability 
    constraints {
        implementation("org.apache.logging.log4j:log4j-core") {
            version {
                strictly("[2.16, 3[")
                prefer("2.16.0")
            }
            because("CVE-2021-44228: Log4j vulnerable to remote code execution")
        }
    }
}


test {
    useJUnitPlatform()

    // Use this flag to show output from running the test
    // testLogging.showStandardStreams = true
}

// This task removes the generated Cloudformation template snapshot during the build process,
// which allows the snapshot to be generated and committed with pull requests without failing builds outright.
task removeSnapshot(type: Delete) {
    delete './src/test/java/com/ilmlf/delivery/DeliveryAppTest.snap'
}

group = 'com.ilmlf.delivery'
version = '0.1'
description = 'api'
java.sourceCompatibility = JavaVersion.VERSION_11

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

test.dependsOn removeSnapshot
