From cf228bebc3ffccbc625366e765508e664e6260ba Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Thu, 14 Jan 2021 16:08:40 +0300 Subject: [PATCH] Use static year range in copyright of generated FIR and tests Dynamically calculating a year is problematic, especially in cases like FIR where generation happens in every build. When you are working on a last year's commit, each build creates a bunch of uncommited changes of updating the year in copyrights. --- compiler/fir/checkers/build.gradle.kts | 1 + compiler/fir/tree/build.gradle.kts | 1 + .../kotlin/fir/tree/generator/printer/main.kt | 9 +-------- .../kotlin/test/generators/NewTestGeneratorImpl.kt | 11 +++-------- .../kotlin/generators/impl/TestGeneratorImpl.kt | 11 +++-------- license/COPYRIGHT_HEADER.txt | 4 ++++ 6 files changed, 13 insertions(+), 24 deletions(-) create mode 100644 license/COPYRIGHT_HEADER.txt diff --git a/compiler/fir/checkers/build.gradle.kts b/compiler/fir/checkers/build.gradle.kts index ff40e2064a1..1129017f095 100644 --- a/compiler/fir/checkers/build.gradle.kts +++ b/compiler/fir/checkers/build.gradle.kts @@ -47,6 +47,7 @@ val generateCheckersComponents by tasks.registering(NoDebugJavaExec::class) { outputs.dirs(generationRoot) args(generationRoot) + workingDir = rootDir classpath = generatorClasspath main = "org.jetbrains.kotlin.fir.checkers.generator.MainKt" systemProperties["line.separator"] = "\n" diff --git a/compiler/fir/tree/build.gradle.kts b/compiler/fir/tree/build.gradle.kts index 56f2560052a..8a6b4d3d1e1 100644 --- a/compiler/fir/tree/build.gradle.kts +++ b/compiler/fir/tree/build.gradle.kts @@ -40,6 +40,7 @@ val generateTree by tasks.registering(NoDebugJavaExec::class) { outputs.dirs(generationRoot) args(generationRoot) + workingDir = rootDir classpath = generatorClasspath main = "org.jetbrains.kotlin.fir.tree.generator.MainKt" systemProperties["line.separator"] = "\n" diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt index 1a25aae8f56..d2881db706a 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt @@ -6,16 +6,9 @@ package org.jetbrains.kotlin.fir.tree.generator.printer import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder - import java.io.File -import java.util.* -private val COPYRIGHT = """ -/* - * Copyright 2010-${GregorianCalendar()[Calendar.YEAR]} JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ -""".trimIndent() +private val COPYRIGHT = File("license/COPYRIGHT_HEADER.txt").readText() const val VISITOR_PACKAGE = "org.jetbrains.kotlin.fir.visitors" const val BASE_PACKAGE = "org.jetbrains.kotlin.fir" diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/generators/NewTestGeneratorImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/generators/NewTestGeneratorImpl.kt index 492f658534f..83feaf37b59 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/generators/NewTestGeneratorImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/generators/NewTestGeneratorImpl.kt @@ -115,14 +115,9 @@ object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) { val out = StringBuilder() val p = Printer(out) - val year = GregorianCalendar()[Calendar.YEAR] - p.println( - """/* - | * Copyright 2010-$year JetBrains s.r.o. and Kotlin Programming Language contributors. - | * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - | */ - |""".trimMargin() - ) + val copyright = File("license/COPYRIGHT_HEADER.txt").readText() + p.println(copyright) + p.println() p.println("package $suiteClassPackage;") p.println() p.println("import com.intellij.testFramework.TestDataPath;") diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/generators/impl/TestGeneratorImpl.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/generators/impl/TestGeneratorImpl.kt index 168d6ba83d9..a3cde41411a 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/generators/impl/TestGeneratorImpl.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/generators/impl/TestGeneratorImpl.kt @@ -111,14 +111,9 @@ private class TestGeneratorImplInstance( val out = StringBuilder() val p = Printer(out) - val year = GregorianCalendar()[Calendar.YEAR] - p.println( - """/* - | * Copyright 2010-$year JetBrains s.r.o. and Kotlin Programming Language contributors. - | * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - | */ - |""".trimMargin() - ) + val copyright = File("license/COPYRIGHT_HEADER.txt").readText() + p.println(copyright) + p.println() p.println("package ", suiteClassPackage, ";") p.println() p.println("import com.intellij.testFramework.TestDataPath;") diff --git a/license/COPYRIGHT_HEADER.txt b/license/COPYRIGHT_HEADER.txt new file mode 100644 index 00000000000..41296a422d3 --- /dev/null +++ b/license/COPYRIGHT_HEADER.txt @@ -0,0 +1,4 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ \ No newline at end of file