From 8fce1022124fcd859e9a3a2971f4cce743bc10c8 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 19 Oct 2015 19:41:23 +0300 Subject: [PATCH] Add script to do padding for teamcity version --- generators/infrastructure/counter-padding.kts | 63 +++++++++++++++++++ update_dependencies.xml | 20 +++++- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 generators/infrastructure/counter-padding.kts diff --git a/generators/infrastructure/counter-padding.kts b/generators/infrastructure/counter-padding.kts new file mode 100644 index 00000000000..ba7bf8cbf10 --- /dev/null +++ b/generators/infrastructure/counter-padding.kts @@ -0,0 +1,63 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.io.File + +fun main(args: Array) { + val filePathDefault = "padded-version.txt" + + if (args.isEmpty() || args.size > 2) { + error("Usage: kotlinc -script counter-padding.kts" + + " " + + " ") + } + + var versionStr = args[0] + + println("Version string: " + versionStr) + + val incrementPartStr = versionStr.takeLastWhile { it.isDigit() } + val versionPrefix = versionStr.take(versionStr.length - incrementPartStr.length) + + val incrementPart = incrementPartStr.toInt() + val padded = java.lang.String.format("%03d", incrementPart) + + var filePath = args.getOrNull(1) ?: filePathDefault + + val result = "${versionPrefix}$padded" + + println("prefix=$versionPrefix incrementPart=$incrementPart result=$padded filePath=$filePath") + + File("$filePath").writeText("$result") +} + +main(args) \ No newline at end of file diff --git a/update_dependencies.xml b/update_dependencies.xml index 2320e43c628..0519547a0ac 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -13,6 +13,9 @@ + + +