Skip to content

Commit

Permalink
Return from compile() function immediately if javaFiles collection …
Browse files Browse the repository at this point in the history
…is empty
  • Loading branch information
baratynskiy authored and mglukhikh committed May 17, 2017
1 parent eb85e9f commit 1eb1735
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,21 @@ class JavacWrapper(javaFiles: Collection<File>,
}
.associateBy(TreeBasedPackage::fqName)

private val kotlinClassifiersCache = KotlinClassifiersCache(kotlinFiles, this)
private val kotlinClassifiersCache = KotlinClassifiersCache(if (javaFiles.isNotEmpty()) kotlinFiles else emptyList(), this)
private val treePathResolverCache = TreePathResolverCache(this)
private val symbolBasedClassesCache = hashMapOf<String, SymbolBasedClass?>()
private val symbolBasedPackagesCache = hashMapOf<String, SymbolBasedPackage?>()

fun compile(outDir: File? = null): Boolean = with(javac) {
if (errorCount() > 0) return false

val javaFilesNumber = fileObjects.length()
if (javaFilesNumber == 0) return true

fileManager.setClassPathForCompilation(outDir)
messageCollector?.report(CompilerMessageSeverity.INFO,
"Compiling Java sources")
"Compiling $javaFilesNumber Java source files" +
" to [${fileManager.getLocation(StandardLocation.CLASS_OUTPUT)?.firstOrNull()?.path}]")
compile(fileObjects)
errorCount() == 0
}
Expand Down

0 comments on commit 1eb1735

Please sign in to comment.