Skip to content

Commit

Permalink
Migrate outdated APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Apr 15, 2023
1 parent f4c7478 commit 4cf325a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.gradle.util.GradleVersion
import org.jetbrains.dokka.DokkaDefaults
import java.util.Locale

open class DokkaPlugin : Plugin<Project> {
override fun apply(project: Project) {
Expand Down Expand Up @@ -106,7 +107,7 @@ open class DokkaPlugin : Plugin<Project> {

private fun Project.configureEachAbstractDokkaTask() {
tasks.withType<AbstractDokkaTask>().configureEach {
val formatClassifier = name.removePrefix("dokka").decapitalize()
val formatClassifier = name.removePrefix("dokka").replaceFirstChar { it.lowercase(Locale.getDefault()) }
outputDirectory.convention(project.layout.buildDirectory.dir("dokka/$formatClassifier"))
cacheRoot.set(DokkaDefaults.cacheRoot)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package org.jetbrains.dokka.gradle

import org.gradle.api.Task
import java.io.File
import java.util.Locale

internal fun Task.defaultDokkaOutputDirectory(): File {
return defaultDokkaOutputDirectory(project.buildDir, name)
}

internal fun defaultDokkaOutputDirectory(buildDir: File, taskName: String): File {
val formatClassifier = taskName.removePrefix("dokka").decapitalize()
val formatClassifier = taskName.removePrefix("dokka").replaceFirstChar { it.lowercase(Locale.getDefault()) }
return File(buildDir, "dokka${File.separator}$formatClassifier")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.android.build.gradle.api.LibraryVariant
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
import java.util.Locale

internal fun Project.isMainSourceSet(sourceSet: KotlinSourceSet): Boolean {
return isMainSourceSet(allCompilationsOf(sourceSet))
Expand All @@ -23,7 +24,7 @@ private fun isMainCompilation(compilation: KotlinCompilation): Boolean {
}
} catch (e: NoSuchMethodError) {
// Kotlin Plugin version below 1.4
return !compilation.name.toLowerCase().endsWith("test")
return !compilation.name.lowercase(Locale.getDefault()).endsWith("test")
}
return compilation.name == "main"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.gradle.api.internal.project.ProjectInternal
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.withType
import org.gradle.testfixtures.ProjectBuilder
import java.util.Locale
import kotlin.test.*

class AndroidAutoConfigurationTest {
Expand Down Expand Up @@ -47,7 +48,7 @@ class AndroidAutoConfigurationTest {
project as ProjectInternal
project.evaluate()
dokkaTasks.flatMap { it.dokkaSourceSets }.forEach { sourceSet ->
if ("test" in sourceSet.name.toLowerCase()) {
if ("test" in sourceSet.name.lowercase(Locale.getDefault())) {
assertTrue(
sourceSet.suppress.get(),
"Expected source set `${sourceSet.name}` to be suppressed by default"
Expand Down

0 comments on commit 4cf325a

Please sign in to comment.