dependencies {
    developmentOnly "org.springframework.boot:spring-boot-devtools"
    // jhipster-needle-gradle-dependency - JHipster will add additional dependencies here
}

springBoot {
    buildInfo {
        excludes = ['time']
    }
}

bootRun {
    args = ["--spring.profiles.active=${springProfiles}"]
}

task webapp(type: NpmTask) {
    inputs.property('appVersion', project.version)
    inputs.files("build.gradle")
        .withPropertyName('build.gradle')
        .withPathSensitivity(PathSensitivity.RELATIVE)
    inputs.files('.postcssrc.js', 'package-lock.json', 'package.json', 'tsconfig.app.json', 'tsconfig.json', 'vite.config.mts')
        .withPropertyName('vue-build')
        .withPathSensitivity(PathSensitivity.RELATIVE)
    inputs.dir("src/main/webapp/")
        .withPropertyName("src/main/webapp/")
        .withPathSensitivity(PathSensitivity.RELATIVE)

    outputs.dir("build/resources/main/static/")
        .withPropertyName("webapp-build-dir")

    dependsOn(npmInstall)

    args = ["run", "webapp:build"]
    environment = [APP_VERSION: project.version]
}

processResources {
    inputs.property('version', version)
    inputs.property('springProfiles', springProfiles)
    filesMatching("**/application.yml") {
        filter {
            it.replace("@project.version@", version)
        }
        filter {
            it.replace("@spring.profiles.active@", springProfiles)
        }
    }
}

task integrationTest(type: Test) {
    maxHeapSize = "1G"
    useJUnitPlatform()
    description = "Execute integration tests."
    group = "verification"
    include "**/*IT*", "**/*IntTest*"
    testLogging {
        events = ['FAILED', 'SKIPPED']
        exceptionFormat = "full"
    }
    systemProperty('spring.profiles.active', springTestProfiles)
    // uncomment if the tests reports are not generated
    // see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484
    // ignoreFailures true
    reports.html.required = false
}
integrationTest.dependsOn(test)

processResources.dependsOn(webapp)
bootJar.dependsOn(processResources)
