in src/main/kotlin/org/jetbrains/kotlin/tools/testutils/testUtils.kt [170:229]
fun buildProject(project: Project?): Boolean {
val finishedLautch = CountDownLatch(1)
if (project == null) {
printMessage("Project is null", MessageStatus.ERROR)
return false
} else {
startOperation(OperationType.COMPILATION, "Compile project with JPS")
var errorsCount = 0
var abortedStatus = false
val compilationStarted = System.nanoTime()
val callback = CompileStatusNotification { aborted, errors, warnings, compileContext ->
run {
try {
errorsCount = errors
abortedStatus = aborted
printMessage("Compilation done. Aborted=$aborted, Errors=$errors, Warnings=$warnings", MessageStatus.WARNING)
reportStatistics("jps_compilation_errors", errors.toString())
reportStatistics("jps_compilation_warnings", warnings.toString())
reportStatistics("jps_compilation_duration", ((System.nanoTime() - compilationStarted) / 1000_000).toString())
CompilerMessageCategory.values().forEach { category ->
compileContext.getMessages(category).forEach {
val message = "$category - ${it.virtualFile?.canonicalPath ?: "-"}: ${it.message}"
when (category) {
CompilerMessageCategory.ERROR -> {
printMessage(message, MessageStatus.ERROR)
//reportTestError("Compile project with JPS", message)
}
CompilerMessageCategory.WARNING -> printMessage(message, MessageStatus.WARNING)
else -> printMessage(message)
}
}
}
} finally {
finishedLautch.countDown()
}
}
}
CompilerConfigurationImpl.getInstance(project).setBuildProcessHeapSize(3500)
CompilerWorkspaceConfiguration.getInstance(project).PARALLEL_COMPILATION = true
val compileContext = InternalCompileDriver(project).rebuild(callback)
while (!finishedLautch.await(1, TimeUnit.MINUTES)) {
if (!compileContext.progressIndicator.isRunning) {
printMessage("Progress indicator says that compilation is not running.", MessageStatus.ERROR)
break
}
printProgress("Compilation status: Errors: ${compileContext.getMessages(CompilerMessageCategory.ERROR).size}. Warnings: ${compileContext.getMessages(CompilerMessageCategory.WARNING).size}.")
}
if (errorsCount > 0 || abortedStatus) {
finishOperation(OperationType.COMPILATION, "Compile project with JPS", "Compilation failed with $errorsCount errors")
return false
} else {
finishOperation(OperationType.COMPILATION, "Compile project with JPS")
}
}
return true
}