Skip to content

Commit df6016d

Browse files
committed
Use correct class folder with Maven
1 parent d8783c3 commit df6016d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

adapter/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ startScripts {
1818

1919
repositories {
2020
mavenCentral()
21+
maven { url 'https://jitpack.io' }
2122
}
2223

2324
dependencies {

adapter/src/main/kotlin/fwcd/ktda/classpath/FindClassPath.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ fun findClassPath(projectRoots: Collection<Path>): Set<Path> {
2626
.toSet()
2727
).ifEmpty(::backupClassPath) +
2828
projectRoots
29+
.asSequence()
2930
.flatMap { findCompiledClassFolders(it) }
3031
.filterNotNull()
3132
}
3233

33-
private val buildDirs = setOf("build", "target")
34-
35-
private fun findCompiledClassFolders(projectRoot: Path): Collection<Path> = Files.list(projectRoot)
36-
.filter { it.fileName.toString() in buildDirs }
37-
.flatMap(Files::list)
38-
.filter { it.fileName.toString() == "classes" }
39-
.flatMap(Files::list) // kotlin, java
40-
.flatMap(Files::list) // main, test
41-
.filter { Files.isDirectory(it) }
42-
.collect(Collectors.toList())
34+
private fun findCompiledClassFolders(projectRoot: Path): Sequence<Path?> = sequenceOf(
35+
// Gradle
36+
sequenceOf("kotlin", "java").flatMap { language ->
37+
sequenceOf("main", "test").map { sourceSet ->
38+
resolveIfExists(projectRoot, "build", "classes", language, sourceSet)
39+
}
40+
},
41+
// Maven
42+
sequenceOf(resolveIfExists(projectRoot, "target", "classes"))
43+
).flatten()
4344

4445
private fun resolveIfExists(root: Path, vararg segments: String): Path? {
4546
var result = root

0 commit comments

Comments
 (0)