Extract throwGradleExceptionIfError
This commit is contained in:
+3
-10
@@ -34,14 +34,6 @@ open class KaptTask : AbstractCompile() {
|
||||
return FileUtil.isAncestor(destinationDir, this, /* strict = */ false)
|
||||
}
|
||||
|
||||
private fun processCompilerExitCode(exitCode: ExitCode) {
|
||||
when (exitCode) {
|
||||
ExitCode.COMPILATION_ERROR -> throw GradleException("Annotation processing error. See log for more details")
|
||||
ExitCode.INTERNAL_ERROR -> throw GradleException("Annotation processing internal error. See log for more details")
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
override fun compile() {
|
||||
/** Delete everything inside the [destinationDir] */
|
||||
@@ -59,8 +51,9 @@ open class KaptTask : AbstractCompile() {
|
||||
kotlinCompileTask.parentKotlinOptionsImpl?.updateArguments(args)
|
||||
KotlinJvmOptionsImpl().updateArguments(args)
|
||||
|
||||
processCompilerExitCode(compileJvmNotIncrementally(compiler, logger,
|
||||
val exitCode = compileJvmNotIncrementally(compiler, logger,
|
||||
sourceRoots.kotlinSourceFiles, sourceRoots.javaSourceRoots, compileClasspath,
|
||||
destinationDir, args))
|
||||
destinationDir, args)
|
||||
throwGradleExceptionIfError(exitCode)
|
||||
}
|
||||
}
|
||||
+1
-8
@@ -222,14 +222,7 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
||||
cleanupOnError()
|
||||
}
|
||||
|
||||
when (exitCode) {
|
||||
ExitCode.COMPILATION_ERROR -> throw GradleException("Compilation error. See log for more details")
|
||||
ExitCode.INTERNAL_ERROR -> throw GradleException("Internal compiler error. See log for more details")
|
||||
ExitCode.SCRIPT_EXECUTION_ERROR -> throw GradleException("Script execution error. See log for more details")
|
||||
ExitCode.OK -> {
|
||||
logger.kotlinInfo("Compilation succeeded")
|
||||
}
|
||||
}
|
||||
throwGradleExceptionIfError(exitCode)
|
||||
}
|
||||
|
||||
private fun handleKaptProperties() {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package org.jetbrains.kotlin.gradle.tasks
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
|
||||
fun throwGradleExceptionIfError(exitCode: ExitCode) {
|
||||
when (exitCode) {
|
||||
ExitCode.COMPILATION_ERROR -> throw GradleException("Compilation error. See log for more details")
|
||||
ExitCode.INTERNAL_ERROR -> throw GradleException("Internal compiler error. See log for more details")
|
||||
ExitCode.SCRIPT_EXECUTION_ERROR -> throw GradleException("Script execution error. See log for more details")
|
||||
ExitCode.OK -> {}
|
||||
else -> throw IllegalStateException("Unexpected exit code: $exitCode")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user