diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-11-07 13:34:32 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-11-07 13:34:32 +0100 |
commit | a0fccbf115d58e0794d33a06ef871a570fcf643e (patch) | |
tree | 323dc30454ba1d5610cbf735955b5e83ab5e84d1 /kvision-tools/kvision-compiler-plugin/src/main/kotlin | |
parent | 81e59d6384b9989161f08a79287670a78be030a4 (diff) | |
download | kvision-a0fccbf115d58e0794d33a06ef871a570fcf643e.tar.gz kvision-a0fccbf115d58e0794d33a06ef871a570fcf643e.tar.bz2 kvision-a0fccbf115d58e0794d33a06ef871a570fcf643e.zip |
Better function to guess the build folder in plugin.
Diffstat (limited to 'kvision-tools/kvision-compiler-plugin/src/main/kotlin')
-rw-r--r-- | kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt b/kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt index 43d83aef..e09c9021 100644 --- a/kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt +++ b/kvision-tools/kvision-compiler-plugin/src/main/kotlin/pl/treksoft/kvision/plugin/KVProcessor.kt @@ -61,9 +61,17 @@ class KVProcessor : AbstractProcessor() { if (it is Element.ClassElement && it.classDescriptor.name.asString().startsWith("I") && it.classDescriptor.name.asString().endsWith("Service") ) { + tailrec fun findBuildFolder(path: String): String { + val preSrcDir = path.substringBeforeLast("/src") + return if (path == preSrcDir || File(preSrcDir, "build").isDirectory) { + "$preSrcDir/build" + } else { + findBuildFolder(preSrcDir) + } + } + val cl = it.classDescriptor - val projectFolder = cl.canonicalFilePath()?.split("/src")?.get(0) ?: "" - val buildFolder = "$projectFolder/build" + val buildFolder = cl.canonicalFilePath()?.let { path -> findBuildFolder(path) } val genRootDir = File(buildFolder, "generated-src").apply { mkdirs() } |