Fix unnecessary usages of Locale.getDefault()
This commit is contained in:
committed by
Space
parent
a9479ec8d7
commit
7157a54155
@@ -131,7 +131,7 @@ fun Project.createGradleCommonSourceSet(): SourceSet {
|
||||
|
||||
// Common outputs will also produce '${project.name}.kotlin_module' file, so we need to avoid
|
||||
// files clash
|
||||
tasks.named<KotlinCompile>("compile${commonSourceSet.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}Kotlin") {
|
||||
tasks.named<KotlinCompile>("compile${commonSourceSet.name.replaceFirstChar { it.uppercase() }}Kotlin") {
|
||||
kotlinOptions {
|
||||
moduleName = "${this@createGradleCommonSourceSet.name}_${commonSourceSet.name}"
|
||||
}
|
||||
@@ -360,11 +360,7 @@ fun Project.createGradlePluginVariant(
|
||||
plugins.withId("org.jetbrains.dokka") {
|
||||
val dokkaTask = tasks.register<DokkaTask>(
|
||||
"dokka${
|
||||
variantSourceSet.javadocTaskName.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
Locale.getDefault()
|
||||
) else it.toString()
|
||||
}
|
||||
variantSourceSet.javadocTaskName.replaceFirstChar { it.uppercase() }
|
||||
}") {
|
||||
description = "Generates documentation in 'javadoc' format for '${variantSourceSet.javadocTaskName}' variant"
|
||||
|
||||
@@ -410,7 +406,7 @@ fun Project.createGradlePluginVariant(
|
||||
}
|
||||
|
||||
// KT-52138: Make module name the same for all variants, so KSP could access internal methods/properties
|
||||
tasks.named<KotlinCompile>("compile${variantSourceSet.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}Kotlin") {
|
||||
tasks.named<KotlinCompile>("compile${variantSourceSet.name.replaceFirstChar { it.uppercase() }}Kotlin") {
|
||||
kotlinOptions {
|
||||
moduleName = this@createGradlePluginVariant.name
|
||||
}
|
||||
@@ -470,7 +466,7 @@ fun Project.publishShadowedJar(
|
||||
val jarTask = tasks.named<Jar>(sourceSet.jarTaskName)
|
||||
|
||||
val shadowJarTask = embeddableCompilerDummyForDependenciesRewriting(
|
||||
taskName = "$EMBEDDABLE_COMPILER_TASK_NAME${sourceSet.jarTaskName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}"
|
||||
taskName = "$EMBEDDABLE_COMPILER_TASK_NAME${sourceSet.jarTaskName.replaceFirstChar { it.uppercase() }}"
|
||||
) {
|
||||
setupPublicJar(
|
||||
jarTask.flatMap { it.archiveBaseName },
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.gradle.api.Project
|
||||
import java.util.*
|
||||
|
||||
data class EndorsedLibraryInfo(val project: Project, val name: String) {
|
||||
|
||||
@@ -9,6 +8,6 @@ data class EndorsedLibraryInfo(val project: Project, val name: String) {
|
||||
get() = project.name
|
||||
|
||||
val taskName: String by lazy {
|
||||
projectName.split('.').joinToString(separator = "") { it.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }
|
||||
projectName.split('.').joinToString(separator = "") { name -> name.replaceFirstChar { it.uppercase() } }
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import java.io.Serializable
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Test task for -produce framework testing. Requires a framework to be built by the Konan plugin
|
||||
@@ -146,9 +145,8 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable {
|
||||
val provider = Paths.get(testOutput, name, "provider.swift")
|
||||
FileWriter(provider.toFile()).use { writer ->
|
||||
val providers = swiftSources.toFiles(Language.Swift)
|
||||
.map {
|
||||
it.name.toString().removeSuffix(".swift")
|
||||
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||
.map { file ->
|
||||
file.name.toString().removeSuffix(".swift").replaceFirstChar { it.uppercase() }
|
||||
}
|
||||
.map { "${it}Tests" }
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ val Project.testTarget
|
||||
get() = findProperty("target") as? KonanTarget ?: HostManager.host
|
||||
|
||||
val Project.testTargetSuffix
|
||||
get() = (findProperty("target") as KonanTarget).name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||
get() = (findProperty("target") as KonanTarget).name.replaceFirstChar { it.uppercase() }
|
||||
|
||||
val Project.verboseTest
|
||||
get() = hasProperty("test_verbose")
|
||||
@@ -214,14 +214,7 @@ fun Project.getFilesToCompile(compile: List<String>, exclude: List<String>): Lis
|
||||
//region Task dependency.
|
||||
|
||||
fun Project.findKonanBuildTask(artifact: String, target: KonanTarget): TaskProvider<Task> =
|
||||
tasks.named(
|
||||
"compileKonan${artifact.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}${
|
||||
target.name.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
Locale.getDefault()
|
||||
) else it.toString()
|
||||
}
|
||||
}")
|
||||
tasks.named("compileKonan${artifact.replaceFirstChar { it.uppercase() }}${target.name.replaceFirstChar { it.uppercase() }}")
|
||||
|
||||
fun Project.dependsOnDist(taskName: String) {
|
||||
project.tasks.getByName(taskName).dependsOnDist()
|
||||
|
||||
+4
-8
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.konan.target.PlatformManager
|
||||
import org.jetbrains.kotlin.konan.target.SanitizerKind
|
||||
import org.jetbrains.kotlin.konan.target.supportedSanitizers
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -54,12 +53,9 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
val sanitizers: List<SanitizerKind?> = target.supportedSanitizers() + listOf(null)
|
||||
sanitizers.forEach { sanitizer ->
|
||||
project.tasks.register(
|
||||
"${targetName}${
|
||||
name.snakeCaseToCamelCase()
|
||||
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||
}${suffixForSanitizer(sanitizer)}",
|
||||
CompileToBitcode::class.java,
|
||||
name, targetName, outputGroup
|
||||
"${targetName}${name.snakeCaseToCamelCase().replaceFirstChar { it.uppercase() }}${suffixForSanitizer(sanitizer)}",
|
||||
CompileToBitcode::class.java,
|
||||
name, targetName, outputGroup
|
||||
).configure {
|
||||
srcDirs = project.files(srcRoot.resolve("cpp"))
|
||||
headersDirs = srcDirs + project.files(srcRoot.resolve("headers"))
|
||||
@@ -82,7 +78,7 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) {
|
||||
companion object {
|
||||
|
||||
private fun String.snakeCaseToCamelCase() =
|
||||
split('_').joinToString(separator = "") { it.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }
|
||||
split('_').joinToString(separator = "") { word -> word.replaceFirstChar { it.uppercase() } }
|
||||
|
||||
fun suffixForSanitizer(sanitizer: SanitizerKind?) =
|
||||
when (sanitizer) {
|
||||
|
||||
+2
-2
@@ -65,10 +65,10 @@ internal class EnvironmentVariablesImpl(val project: Project): EnvironmentVaria
|
||||
}
|
||||
|
||||
override val debuggingSymbols: Boolean
|
||||
get() = System.getenv("DEBUGGING_SYMBOLS")?.uppercase(Locale.getDefault()) == "YES"
|
||||
get() = System.getenv("DEBUGGING_SYMBOLS")?.uppercase() == "YES"
|
||||
|
||||
override val enableOptimizations: Boolean
|
||||
get() = System.getenv("KONAN_ENABLE_OPTIMIZATIONS")?.uppercase(Locale.getDefault()) == "YES"
|
||||
get() = System.getenv("KONAN_ENABLE_OPTIMIZATIONS")?.uppercase() == "YES"
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-14
@@ -81,25 +81,13 @@ abstract class KonanBuildingConfig<T : KonanBuildingTask>(
|
||||
}
|
||||
|
||||
protected open fun generateTaskName(target: KonanTarget) =
|
||||
"compileKonan${name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}${
|
||||
target.visibleName.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
Locale.getDefault()
|
||||
) else it.toString()
|
||||
}
|
||||
}"
|
||||
"compileKonan${name.replaceFirstChar { it.uppercase() }}${target.visibleName.replaceFirstChar { it.uppercase() }}"
|
||||
|
||||
protected open fun generateAggregateTaskName() =
|
||||
"compileKonan${name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}"
|
||||
|
||||
protected open fun generateTargetAliasTaskName(targetName: String) =
|
||||
"compileKonan${name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}${
|
||||
targetName.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
Locale.getDefault()
|
||||
) else it.toString()
|
||||
}
|
||||
}"
|
||||
"compileKonan${name.replaceFirstChar { it.uppercase() }}${targetName.replaceFirstChar { it.uppercase() }}"
|
||||
|
||||
protected abstract fun generateTaskDescription(task: T): String
|
||||
protected abstract fun generateAggregateTaskDescription(task: Task): String
|
||||
|
||||
+2
-11
@@ -22,7 +22,6 @@ import org.gradle.api.*
|
||||
import org.gradle.api.component.ComponentWithVariants
|
||||
import org.gradle.api.component.SoftwareComponent
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.internal.FeaturePreviews
|
||||
import org.gradle.api.internal.component.SoftwareComponentInternal
|
||||
import org.gradle.api.internal.component.UsageContext
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
@@ -44,7 +43,6 @@ import org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin.Companion.COMPILE_AL
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.*
|
||||
import org.jetbrains.kotlin.konan.CURRENT
|
||||
import org.jetbrains.kotlin.konan.CompilerVersion
|
||||
import org.jetbrains.kotlin.konan.parseCompilerVersion
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.buildDistribution
|
||||
@@ -52,7 +50,6 @@ import org.jetbrains.kotlin.konan.target.customerDistribution
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
import org.jetbrains.kotlin.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -396,14 +393,8 @@ class KonanPlugin @Inject constructor(private val registry: ToolingModelBuilderR
|
||||
val isCrossCompile = (task.target != HostManager.host.visibleName)
|
||||
if (!isCrossCompile && !project.hasProperty("konanNoRun"))
|
||||
task.runTask = project.tasks.register(
|
||||
"run${
|
||||
task.artifactName.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(
|
||||
Locale.getDefault()
|
||||
) else it.toString()
|
||||
}
|
||||
}", Exec::class.java) {
|
||||
group= "run"
|
||||
"run${task.artifactName.replaceFirstChar { it.uppercase() }}", Exec::class.java) {
|
||||
group = "run"
|
||||
dependsOn(task)
|
||||
val artifactPathClosure = object : Closure<String>(this) {
|
||||
override fun call() = task.artifactPath
|
||||
|
||||
+1
-2
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.gradle.kpm.external.createExternalJvmVariant
|
||||
import org.jetbrains.kotlin.gradle.kpm.external.external
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.*
|
||||
import java.util.*
|
||||
|
||||
fun KotlinGradleModule.createKotlinAndroidVariant(androidVariant: BaseVariant) {
|
||||
val androidOutgoingArtifacts = FragmentArtifacts<KotlinJvmVariant> {
|
||||
@@ -45,7 +44,7 @@ fun KotlinGradleModule.createKotlinAndroidVariant(androidVariant: BaseVariant) {
|
||||
}
|
||||
|
||||
val kotlinVariant = createExternalJvmVariant(
|
||||
"android${androidVariant.buildType.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}", KotlinJvmVariantConfig(
|
||||
"android${androidVariant.buildType.name.replaceFirstChar { it.uppercase() }}", KotlinJvmVariantConfig(
|
||||
/* Only swap out configuration that is used. Default setup shall still be applied */
|
||||
compileDependencies = (DefaultKotlinCompileDependenciesDefinition +
|
||||
FragmentAttributes<KotlinGradleFragment> {
|
||||
|
||||
@@ -106,9 +106,8 @@ class ModelParser(private val variant: Variant, private val modulePrefix: String
|
||||
private fun findEmbeddableTask(project: Project, sourceSet: SourceSet): Jar? {
|
||||
val jarName = sourceSet.jarTaskName
|
||||
val embeddable = "embeddable"
|
||||
val embeddedName = if (jarName == "jar") embeddable else jarName.dropLast("jar".length) + embeddable.replaceFirstChar {
|
||||
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
|
||||
}
|
||||
val embeddedName = if (jarName == "jar") embeddable else jarName.dropLast("jar".length) +
|
||||
embeddable.replaceFirstChar { it.uppercase() }
|
||||
return project.tasks.findByName(embeddedName) as? Jar
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user