File tree Expand file tree Collapse file tree
main/kotlin/modulecheck/core/context
test/kotlin/modulecheck/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ data class MustBeApi(
100100 .distinctBy { it.path }
101101 .filterNot { cpd ->
102102 // exclude anything which is inherited but already included in local `api` deps
103- cpd in directApiProjects
103+ cpd.copy(configurationName = cpd.configurationName.apiVariant()) in directApiProjects
104104 }
105105 .filterAsync {
106106 ! sourceSetName.isTestingOnly() && it.project(project.projectCache)
Original file line number Diff line number Diff line change @@ -643,6 +643,63 @@ class MustBeApiTest : RunnerTest() {
643643 logger.parsedReport() shouldBe listOf ()
644644 }
645645
646+ @Test
647+ fun `api and implementation of the same dependency with auto-correct should not be changed` () {
648+
649+ val lib1 = kotlinProject(" :lib1" ) {
650+ addKotlinSource(
651+ """
652+ package com.modulecheck.lib1
653+
654+ class Lib1Class
655+ """
656+ )
657+ }
658+
659+ val lib2 = kotlinProject(" :lib2" ) {
660+ addDependency(ConfigurationName .api, lib1)
661+ addDependency(ConfigurationName .implementation, lib1)
662+
663+ buildFile {
664+ """
665+ plugins {
666+ kotlin("jvm")
667+ }
668+
669+ dependencies {
670+ api(project(path = ":lib1"))
671+ implementation(project(path = ":lib1"))
672+ }
673+ """
674+ }
675+
676+ addKotlinSource(
677+ """
678+ package com.modulecheck.lib2
679+
680+ import com.modulecheck.lib1.Lib1Class
681+
682+ val lib1Class = Lib1Class()
683+ """
684+ )
685+ }
686+
687+ run ().isSuccess shouldBe true
688+
689+ lib2.buildFile shouldHaveText """
690+ plugins {
691+ kotlin("jvm")
692+ }
693+
694+ dependencies {
695+ api(project(path = ":lib1"))
696+ implementation(project(path = ":lib1"))
697+ }
698+ """
699+
700+ logger.parsedReport() shouldBe listOf ()
701+ }
702+
646703 @Test
647704 fun `public property from dependency in test source should not require API` () {
648705
You can’t perform that action at this time.
0 commit comments