Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ internal class DefaultConfigTests : BaseKotlinGradleTest() {
}
}

@Test
fun `apiCheck should succeed when public classes match api file ignoring case`() {
val runner = test {
buildGradleKts {
resolve("examples/gradle/base/withPlugin.gradle.kts")
}
kotlin("AnotherBuildConfig.kt") {
resolve("examples/classes/AnotherBuildConfig.kt")
}
apiFile(projectName = rootProjectDir.name.toUpperCase()) {
resolve("examples/classes/AnotherBuildConfig.dump")
}

runner {
arguments.add(":apiCheck")
}
}

runner.build().apply {
assertTaskSuccess(":apiCheck")
}
}

@Test
fun `apiCheck should fail, when a public class is not in api-File`() {
val runner = test {
Expand Down
7 changes: 6 additions & 1 deletion src/main/kotlin/ApiCompareCompareTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.gradle.api.file.*
import org.gradle.api.model.ObjectFactory
import org.gradle.api.tasks.*
import java.io.*
import java.util.TreeSet
import javax.inject.Inject

open class ApiCompareCompareTask @Inject constructor(private val objects: ObjectFactory): DefaultTask() {
Expand Down Expand Up @@ -53,7 +54,11 @@ open class ApiCompareCompareTask @Inject constructor(private val objects: Object

val subject = projectName
val apiBuildDirFiles = mutableSetOf<RelativePath>()
val expectedApiFiles = mutableSetOf<RelativePath>()
// We use case-insensitive comparison to workaround issues with case-insensitive OSes
// and Gradle behaving slightly different on different platforms
val expectedApiFiles = TreeSet<RelativePath> { rp, rp2 ->
rp.toString().compareTo(rp2.toString(), true)
}
objects.fileTree().from(apiBuildDir).visit { file ->
apiBuildDirFiles.add(file.relativePath)
}
Expand Down