diff --git a/libraries/stdlib/common/src/generated/_Arrays.kt b/libraries/stdlib/common/src/generated/_Arrays.kt index 0e3d039c717..3f5397fe4f1 100644 --- a/libraries/stdlib/common/src/generated/_Arrays.kt +++ b/libraries/stdlib/common/src/generated/_Arrays.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("ArraysKt") package kotlin.collections // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/common/src/generated/_Collections.kt b/libraries/stdlib/common/src/generated/_Collections.kt index e4b5e2c5131..1e8258bb541 100644 --- a/libraries/stdlib/common/src/generated/_Collections.kt +++ b/libraries/stdlib/common/src/generated/_Collections.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("CollectionsKt") package kotlin.collections // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/common/src/generated/_Comparisons.kt b/libraries/stdlib/common/src/generated/_Comparisons.kt index b05ef1eb44b..4f667094100 100644 --- a/libraries/stdlib/common/src/generated/_Comparisons.kt +++ b/libraries/stdlib/common/src/generated/_Comparisons.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("ComparisonsKt") package kotlin.comparisons // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/common/src/generated/_Maps.kt b/libraries/stdlib/common/src/generated/_Maps.kt index 37bdbcc315f..667076e802b 100644 --- a/libraries/stdlib/common/src/generated/_Maps.kt +++ b/libraries/stdlib/common/src/generated/_Maps.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("MapsKt") package kotlin.collections // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/common/src/generated/_Ranges.kt b/libraries/stdlib/common/src/generated/_Ranges.kt index d164d5c2003..ecacb0021e7 100644 --- a/libraries/stdlib/common/src/generated/_Ranges.kt +++ b/libraries/stdlib/common/src/generated/_Ranges.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("RangesKt") package kotlin.ranges // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/common/src/generated/_Sequences.kt b/libraries/stdlib/common/src/generated/_Sequences.kt index 2e664c58505..1c720363db3 100644 --- a/libraries/stdlib/common/src/generated/_Sequences.kt +++ b/libraries/stdlib/common/src/generated/_Sequences.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("SequencesKt") package kotlin.sequences // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/common/src/generated/_Sets.kt b/libraries/stdlib/common/src/generated/_Sets.kt index be1e6a382d2..6ca289ed7ae 100644 --- a/libraries/stdlib/common/src/generated/_Sets.kt +++ b/libraries/stdlib/common/src/generated/_Sets.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("SetsKt") package kotlin.collections // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/common/src/generated/_Strings.kt b/libraries/stdlib/common/src/generated/_Strings.kt index 529d0c9fa70..8e32c35d2c1 100644 --- a/libraries/stdlib/common/src/generated/_Strings.kt +++ b/libraries/stdlib/common/src/generated/_Strings.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("StringsKt") package kotlin.text // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/js/src/generated/_ArraysJs.kt b/libraries/stdlib/js/src/generated/_ArraysJs.kt index b0e45391012..0f633af7415 100644 --- a/libraries/stdlib/js/src/generated/_ArraysJs.kt +++ b/libraries/stdlib/js/src/generated/_ArraysJs.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("ArraysKt") package kotlin.collections // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/js/src/generated/_CollectionsJs.kt b/libraries/stdlib/js/src/generated/_CollectionsJs.kt index f79b61469f3..22f9ff19806 100644 --- a/libraries/stdlib/js/src/generated/_CollectionsJs.kt +++ b/libraries/stdlib/js/src/generated/_CollectionsJs.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("CollectionsKt") package kotlin.collections // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/js/src/generated/_ComparisonsJs.kt b/libraries/stdlib/js/src/generated/_ComparisonsJs.kt index 3855e402848..3f942c0eee5 100644 --- a/libraries/stdlib/js/src/generated/_ComparisonsJs.kt +++ b/libraries/stdlib/js/src/generated/_ComparisonsJs.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("ComparisonsKt") package kotlin.comparisons // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt b/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt index 30d0ad145ac..16a3c573a16 100644 --- a/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("ArraysKt") package kotlin.collections // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/jvm/src/generated/_CollectionsJvm.kt b/libraries/stdlib/jvm/src/generated/_CollectionsJvm.kt index ef4a0287daf..13a746fe6b8 100644 --- a/libraries/stdlib/jvm/src/generated/_CollectionsJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_CollectionsJvm.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("CollectionsKt") package kotlin.collections // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/jvm/src/generated/_ComparisonsJvm.kt b/libraries/stdlib/jvm/src/generated/_ComparisonsJvm.kt index 9dbd8ca29f5..7d0159442c6 100644 --- a/libraries/stdlib/jvm/src/generated/_ComparisonsJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_ComparisonsJvm.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("ComparisonsKt") package kotlin.comparisons // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/jvm/src/generated/_SequencesJvm.kt b/libraries/stdlib/jvm/src/generated/_SequencesJvm.kt index bca7d491c18..a1971cfcb8a 100644 --- a/libraries/stdlib/jvm/src/generated/_SequencesJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_SequencesJvm.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("SequencesKt") package kotlin.sequences // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/stdlib/jvm/src/generated/_StringsJvm.kt b/libraries/stdlib/jvm/src/generated/_StringsJvm.kt index 649d84b5578..6d441fcde2f 100644 --- a/libraries/stdlib/jvm/src/generated/_StringsJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_StringsJvm.kt @@ -1,10 +1,15 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmName("StringsKt") package kotlin.text // -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // diff --git a/libraries/tools/kotlin-stdlib-gen/build.gradle b/libraries/tools/kotlin-stdlib-gen/build.gradle index 7d2e97900b6..2073d97ea24 100644 --- a/libraries/tools/kotlin-stdlib-gen/build.gradle +++ b/libraries/tools/kotlin-stdlib-gen/build.gradle @@ -12,8 +12,8 @@ dependencies { compileKotlin { compilerJarFile = null kotlinOptions { - languageVersion = "1.1" - apiVersion = "1.1" + languageVersion = "1.2" + apiVersion = "1.2" freeCompilerArgs = ["-version", "-Xnormalize-constructor-calls=enable"] } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt index d152e47389a..0f1b5a4b0c2 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt @@ -1,3 +1,8 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + package generators import java.io.* @@ -32,6 +37,8 @@ fun main(args: Array) { require(args.size == 1) { "Expecting Kotlin project home path as an argument" } val baseDir = File(args.first()) + COPYRIGHT_NOTICE = readCopyrightNoticeFromProfile(baseDir.resolve(".idea/copyright/apache.xml")) + fun File.resolveExistingDir(subpath: String) = resolve(subpath).also { require(it.isDirectory) { "Directory $it doesn't exist"} } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/Writers.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/Writers.kt index 14769ad2883..65c092d9041 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/Writers.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/dsl/Writers.kt @@ -1,29 +1,34 @@ /* - * Copyright 2010-2017 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-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package templates +import org.xml.sax.InputSource import java.io.File import java.io.FileWriter +import javax.xml.xpath.XPathFactory val COMMON_AUTOGENERATED_WARNING: String = """// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib //""" +lateinit var COPYRIGHT_NOTICE: String + +fun readCopyrightNoticeFromProfile(copyrightProfile: File): String { + val template = copyrightProfile.reader().use { reader -> + XPathFactory.newInstance().newXPath().evaluate("/component/copyright/option[@name='notice']/@value", InputSource(reader)) + } + val yearTemplate = "$today.year" + val year = java.time.LocalDate.now().year.toString() + assert(yearTemplate in template) + + return template.replace(yearTemplate, year).lines().joinToString("", prefix = "/*\n", postfix = " */\n") { " * $it\n" } +} + + data class PlatformSourceFile( val platform: Platform, val sourceFile: SourceFile @@ -67,6 +72,7 @@ fun List.writeTo(file: File, platformSource: PlatformSourceFile) println("Generating file: $file") file.parentFile.mkdirs() FileWriter(file).use { writer -> + writer.appendln(COPYRIGHT_NOTICE) if (sourceFile.multifile) { writer.appendln("@file:kotlin.jvm.JvmMultifileClass") }