Skip to content

Commit

Permalink
MBS-12266 Clean up in module types plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeniy Krivobokov committed Dec 2, 2021
1 parent 937f327 commit 9637d8a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ include(":subprojects:gradle:graphite-config")
include(":subprojects:gradle:impact")
include(":subprojects:gradle:impact-shared")
include(":subprojects:gradle:module-dependencies-graph")
include(":subprojects:gradle:module-dependencies-shared")
include(":subprojects:gradle:module-dependencies")
include(":subprojects:gradle:module-types")
include(":subprojects:gradle:pre-build")
include(":subprojects:gradle:process")
Expand Down
2 changes: 1 addition & 1 deletion subprojects/gradle/impact-shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

dependencies {
api(projects.subprojects.gradle.moduleDependenciesShared)
api(projects.subprojects.gradle.moduleDependencies)

implementation(gradleApi())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
dependencies {
compileOnly(gradleApi())

implementation(projects.subprojects.gradle.moduleDependenciesShared)
implementation(projects.subprojects.gradle.moduleDependencies)
implementation(projects.subprojects.common.math)
implementation(projects.subprojects.gradle.gradleExtensions)

Expand Down
2 changes: 1 addition & 1 deletion subprojects/gradle/module-types/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

dependencies {
api(projects.subprojects.gradle.moduleDependenciesShared)
api(projects.subprojects.gradle.moduleDependencies)

implementation(projects.subprojects.gradle.gradleExtensions)
implementation(projects.subprojects.common.problem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ internal class ModuleTypesTest : BaseModuleTypesTest() {
)
}

@Test
fun `forbidden dependency in implementation - success - warning severity`() {
givenProject(
severity = Severity.warning,
moduleType = LibraryModule,
dependency = Dependency(FeatureModule),
constraint = Constraint(module = LibraryModule, dependency = FeatureModule)
)

val result = runCheck(projectDir, expectFailure = false)

result.assertThat().outputContains(briefErrorMessage)
}

@Test
fun `forbidden test dependency in implementation - failure`() {
givenProject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ public class DependencyRestriction(
public val exclusions: Set<DependencyMatcher> = emptySet(),
@Deprecated("Use matcher's description instead. This property is not used and will be deleted.")
public val description: String = ""
)
) {

internal fun DependencyRestriction.isViolated(
module: ModuleWithType,
dependency: ModuleWithType,
configuration: ConfigurationType
): Boolean {
val isExcluded = exclusions.any {
it.matches(module, dependency, configuration)
internal fun isViolated(
module: ModuleWithType,
dependency: ModuleWithType,
configuration: ConfigurationType
): Boolean {
val isExcluded = exclusions.any {
it.matches(module, dependency, configuration)
}
return !isExcluded && matcher.matches(module, dependency, configuration)
}
return !isExcluded && matcher.matches(module, dependency, configuration)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.avito.android.Problem
import com.avito.android.asRuntimeException
import com.avito.android.module_type.DependencyRestriction
import com.avito.android.module_type.ModuleWithType
import com.avito.android.module_type.isViolated
import com.avito.android.module_type.pluginId
import com.avito.module.configurations.ConfigurationType

Expand Down

0 comments on commit 9637d8a

Please sign in to comment.