Skip to content

Commit 309f5be

Browse files
committed
Fixing Kotlin annotations architecture rule
See gh-34276
1 parent 1bd9848 commit 309f5be

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

buildSrc/src/main/java/org/springframework/build/architecture/ArchitectureRules.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.build.architecture;
1818

19+
import com.tngtech.archunit.base.DescribedPredicate;
1920
import com.tngtech.archunit.core.domain.JavaClass;
2021
import com.tngtech.archunit.lang.ArchRule;
2122
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition;
@@ -66,8 +67,14 @@ static ArchRule classesShouldNotImportForbiddenTypes() {
6667

6768
static ArchRule javaClassesShouldNotImportKotlinAnnotations() {
6869
return ArchRuleDefinition.noClasses()
69-
.that().haveSimpleNameNotEndingWith("Kt")
70-
.and().haveSimpleNameNotEndingWith("Dsl")
70+
.that(new DescribedPredicate<JavaClass>("is not a Kotlin class") {
71+
@Override
72+
public boolean test(JavaClass javaClass) {
73+
return javaClass.getSourceCodeLocation()
74+
.getSourceFileName().endsWith(".java");
75+
}
76+
}
77+
)
7178
.should().dependOnClassesThat()
7279
.resideInAnyPackage("org.jetbrains.annotations..")
7380
.allowEmptyShould(true);

0 commit comments

Comments
 (0)