From 481e3f0b3eaf214c6716d8bd2a9ec43cbd56d186 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 9 Dec 2015 17:24:21 +0300 Subject: [PATCH] never downgrade Kotlin version when updating from sources: if currently bundled Kotlin plugin is newer than build/kotlinc, use the bundled plugin --- build/scripts/download_kotlin.gant | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/build/scripts/download_kotlin.gant b/build/scripts/download_kotlin.gant index 14e52d73646a..58d9c0ab65e7 100644 --- a/build/scripts/download_kotlin.gant +++ b/build/scripts/download_kotlin.gant @@ -24,8 +24,25 @@ target('default': 'Ensures that build/kotlinc directory contains JARs from Kotli def communityHome = guessHome(this) def reasonToUpdate = getReasonToUpdate(communityHome, new File(communityHome, "build/kotlinc")) if (reasonToUpdate == null) { - projectBuilder.info("Compatible Kotlin plugin already installed, no update is required") - return + if (isDefined("workIdeaHome")) { + def workKotlinVersionFile = new File(workIdeaHome, "plugins/Kotlin/kotlinc/build.txt") + if (workKotlinVersionFile.exists()) { + try { + def currentKotlinVersionFile = new File(communityHome, "build/kotlinc/build.txt") + if (VersionComparatorUtil.compare(currentKotlinVersionFile.text, workKotlinVersionFile.text) < 0) { + reasonToUpdate = "a newer version is installed in $workIdeaHome" + } + } + catch (IOException e) { + reasonToUpdate = "cannot read Kotlin version: $e" + } + } + } + + if (reasonToUpdate == null) { + projectBuilder.info("Compatible Kotlin plugin already installed, no update is required") + return + } } projectBuilder.info("Kotlin plugin will be updated: $reasonToUpdate")