From 1c3fb97826de1460e873ee285374873cca796679 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 26 May 2022 21:48:56 +0300 Subject: [PATCH] Fix task outputs for build date --- build.gradle.kts | 10 +++++++--- src/main/kotlin/ru/mipt/spc/Application.kt | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 09c35fd..f5f5432 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -57,10 +57,14 @@ sourceSets { } } -//write build time in build to check outdated external data directory -tasks.getByName("processResources") { +val writeBuildDate: Task by tasks.creating { doFirst { val deployDate = LocalDateTime.now() project.buildDir.resolve("resources/main/buildDate").writeText(deployDate.toString()) } -} \ No newline at end of file + outputs.file("resources/main/buildDate") +} + + +//write build time in build to check outdated external data directory +tasks.getByName("processResources").dependsOn(writeBuildDate) \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/spc/Application.kt b/src/main/kotlin/ru/mipt/spc/Application.kt index 05ea033..1908458 100644 --- a/src/main/kotlin/ru/mipt/spc/Application.kt +++ b/src/main/kotlin/ru/mipt/spc/Application.kt @@ -58,7 +58,11 @@ fun Application.spcModule() { val inProduction: Boolean = environment.config.propertyOrNull("ktor.environment.production") != null - if(inProduction) log.info("Production mode activated") + if(inProduction){ + log.info("Production mode activated") + log.info("Build date: $buildDate") + log.info("Deploy date: $deployDate") + } if (deployDate != null && buildDate != null && buildDate.isAfter(deployDate)) { log.info("Outdated data. Resetting data directory.")