Skip to content

Commit

Permalink
Engine fix : The default KBean was not chosen according alphabetic order
Browse files Browse the repository at this point in the history
  • Loading branch information
djeang committed Nov 20, 2024
1 parent b1d3f85 commit 4f9eddd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dev.jeka.core/src/main/java/dev/jeka/core/tool/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ class Engine {
private static final JkPathMatcher KOTLIN_DEF_SOURCE_MATCHER = JkPathMatcher.of(true, "**.kt")
.and(false, "**/_*", "_*");

private static final Comparator<Path> PATH_COMPARATOR = (o1, o2) -> {
if (o1.getNameCount() < o2.getNameCount()) {
return -1;
}
if (o1.getNameCount() > o2.getNameCount()) {
return 1;
}
return o1.compareTo(o2);
};

static final JkPathMatcher JAVA_OR_KOTLIN_SOURCE_MATCHER = JAVA_DEF_SOURCE_MATCHER.or(KOTLIN_DEF_SOURCE_MATCHER);


Expand Down Expand Up @@ -271,6 +281,7 @@ KBeanResolution resolveKBeans() {
.excludeDirectories()
.relativizeFromRoot()
.filter(path -> path.getFileName().toString().endsWith(".class"))
.sorted(PATH_COMPARATOR)
.map(Engine::classNameFromClassFilePath)
.filter(kbeanClassNames::contains)
.collect(Collectors.toList());
Expand Down

0 comments on commit 4f9eddd

Please sign in to comment.