stdlib-gen: simpify copyright notice reading

This commit is contained in:
Ilya Gorbunov
2022-03-10 23:20:08 +03:00
committed by Space
parent d225399241
commit 4709e2c274
4 changed files with 4 additions and 13 deletions
@@ -35,9 +35,6 @@ fun main(args: Array<String>) {
ComparableOps
)
COPYRIGHT_NOTICE =
readCopyrightNoticeFromProfile { Thread.currentThread().contextClassLoader.getResourceAsStream("apache.xml")!!.reader() }
val targetBaseDirs = mutableMapOf<KotlinTarget, File>()
when (args.size) {
@@ -2,7 +2,6 @@ package generators.math
import templates.COPYRIGHT_NOTICE
import templates.autoGeneratedWarning
import templates.readCopyrightNoticeFromProfile
import java.io.File
import java.io.FileWriter
import kotlin.math.*
@@ -20,9 +19,6 @@ fun main(args: Array<String>) {
}
}
COPYRIGHT_NOTICE =
readCopyrightNoticeFromProfile { Thread.currentThread().contextClassLoader.getResourceAsStream("apache.xml")!!.reader() }
generateUtils(baseDir.resolve("mathTestUtils.kt"))
val trigonometryFunctions = listOf(
@@ -14,9 +14,7 @@ import generators.unicode.mappings.string.StringLowercaseGenerator
import generators.unicode.mappings.string.StringUppercaseGenerator
import generators.unicode.ranges.OtherLowercaseRangesGenerator
import generators.unicode.ranges.OtherUppercaseRangesGenerator
import templates.COPYRIGHT_NOTICE
import templates.KotlinTarget
import templates.readCopyrightNoticeFromProfile
import java.io.File
import java.net.URL
import kotlin.system.exitProcess
@@ -167,9 +165,6 @@ fun main(args: Array<String>) {
}
}
COPYRIGHT_NOTICE =
readCopyrightNoticeFromProfile { Thread.currentThread().contextClassLoader.getResourceAsStream("apache.xml").reader() }
categoryRangesGenerators.forEach {
bmpUnicodeDataLines.forEach { line -> it.appendLine(line) }
it.generate()
@@ -16,7 +16,7 @@ fun autoGeneratedWarning(generator: String): String = """//
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//"""
lateinit var COPYRIGHT_NOTICE: String
val COPYRIGHT_NOTICE: String by lazy { readCopyrightNoticeFromResource() }
fun readCopyrightNoticeFromProfile(copyrightProfile: File): String = readCopyrightNoticeFromProfile { copyrightProfile.reader() }
@@ -31,6 +31,9 @@ fun readCopyrightNoticeFromProfile(getCopyrightReader: () -> Reader): String {
return template.replace(yearTemplate, year).lines().joinToString("", prefix = "/*\n", postfix = " */\n") { " * $it\n" }
}
fun readCopyrightNoticeFromResource() = readCopyrightNoticeFromProfile { Thread.currentThread().contextClassLoader.getResourceAsStream("apache.xml")!!.reader() }
data class TargetedSourceFile(
val target: KotlinTarget,