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 @@ -100,7 +100,7 @@ data class MustBeApi(
.distinctBy { it.path }
.filterNot { cpd ->
// exclude anything which is inherited but already included in local `api` deps
cpd in directApiProjects
cpd.copy(configurationName = cpd.configurationName.apiVariant()) in directApiProjects
}
.filterAsync {
!sourceSetName.isTestingOnly() && it.project(project.projectCache)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,63 @@ class MustBeApiTest : RunnerTest() {
logger.parsedReport() shouldBe listOf()
}

@Test
fun `api and implementation of the same dependency with auto-correct should not be changed`() {

val lib1 = kotlinProject(":lib1") {
addKotlinSource(
"""
package com.modulecheck.lib1

class Lib1Class
"""
)
}

val lib2 = kotlinProject(":lib2") {
addDependency(ConfigurationName.api, lib1)
addDependency(ConfigurationName.implementation, lib1)

buildFile {
"""
plugins {
kotlin("jvm")
}

dependencies {
api(project(path = ":lib1"))
implementation(project(path = ":lib1"))
}
"""
}

addKotlinSource(
"""
package com.modulecheck.lib2

import com.modulecheck.lib1.Lib1Class

val lib1Class = Lib1Class()
"""
)
}

run().isSuccess shouldBe true

lib2.buildFile shouldHaveText """
plugins {
kotlin("jvm")
}

dependencies {
api(project(path = ":lib1"))
implementation(project(path = ":lib1"))
}
"""

logger.parsedReport() shouldBe listOf()
}

@Test
fun `public property from dependency in test source should not require API`() {

Expand Down