Skip to content

Commit

Permalink
Fixing Kotlin annotations architecture rule
Browse files Browse the repository at this point in the history
  • Loading branch information
bclozel committed Jan 17, 2025
1 parent 1bd9848 commit 309f5be
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.build.architecture;

import com.tngtech.archunit.base.DescribedPredicate;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition;
Expand Down Expand Up @@ -66,8 +67,14 @@ static ArchRule classesShouldNotImportForbiddenTypes() {

static ArchRule javaClassesShouldNotImportKotlinAnnotations() {
return ArchRuleDefinition.noClasses()
.that().haveSimpleNameNotEndingWith("Kt")
.and().haveSimpleNameNotEndingWith("Dsl")
.that(new DescribedPredicate<JavaClass>("is not a Kotlin class") {
@Override
public boolean test(JavaClass javaClass) {
return javaClass.getSourceCodeLocation()
.getSourceFileName().endsWith(".java");
}
}
)
.should().dependOnClassesThat()
.resideInAnyPackage("org.jetbrains.annotations..")
.allowEmptyShould(true);
Expand Down

0 comments on commit 309f5be

Please sign in to comment.