fix NPE with logger, delete extracted annotations

This commit is contained in:
Leonid Shalupov
2013-03-15 20:31:29 +04:00
committed by Andrey Breslav
parent 01203f6be3
commit 05285c8272
2 changed files with 13 additions and 8 deletions
@@ -0,0 +1,5 @@
<root>
<item name='org.gradle.api.logging.Logging org.gradle.api.logging.Logger getLogger(java.lang.Class)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>
@@ -27,6 +27,8 @@ import org.jetbrains.jet.cli.common.messages.MessageCollector
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation
import org.gradle.api.logging.Logger import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.apache.commons.io.FileUtils
public open class KotlinCompile(): AbstractCompile() { public open class KotlinCompile(): AbstractCompile() {
@@ -91,8 +93,7 @@ public open class KotlinCompile(): AbstractCompile() {
args.setSourceDirs(sources.map { it.getAbsolutePath() }) args.setSourceDirs(sources.map { it.getAbsolutePath() })
// todo: WTF absolute == gradle class path? val gradleClasspath = getClasspath()
val gradleClasspath = getClasspath().filter(KSpec { it != null && it.isAbsolute() })
val effectiveClassPath = (javaSrcRoots + gradleClasspath).makeString(File.pathSeparator) val effectiveClassPath = (javaSrcRoots + gradleClasspath).makeString(File.pathSeparator)
args.setClasspath(effectiveClassPath) args.setClasspath(effectiveClassPath)
@@ -104,19 +105,17 @@ public open class KotlinCompile(): AbstractCompile() {
args.annotations = embeddedAnnotations.getPath() args.annotations = embeddedAnnotations.getPath()
args.noStdlib = true args.noStdlib = true
val messageCollector = GradleMessageCollector(getLogger()) val logger = Logging.getLogger(getClass())
val messageCollector = GradleMessageCollector(logger)
val exitCode = compiler.exec(messageCollector, args) val exitCode = compiler.exec(messageCollector, args)
if (embeddedAnnotations.getParentFile()?.delete() != true) { FileUtils.deleteDirectory(embeddedAnnotations.getParentFile());
throw GradleException("Can't delete extracted annotations " + embeddedAnnotations)
}
when (exitCode) { when (exitCode) {
ExitCode.COMPILATION_ERROR -> throw GradleException("Compilation error. See log for more details") 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.INTERNAL_ERROR -> throw GradleException("Internal compiler error. See log for more details")
else -> {} else -> {}
} }
} }
fun getAnnotations(): File { fun getAnnotations(): File {
@@ -205,7 +204,8 @@ public open class KDoc(): SourceTask() {
val compiler = KDocCompiler() val compiler = KDocCompiler()
val messageCollector = GradleMessageCollector(getLogger()) val logger = Logging.getLogger(getClass())
val messageCollector = GradleMessageCollector(logger)
val exitCode = compiler.exec(messageCollector, args); val exitCode = compiler.exec(messageCollector, args);
when (exitCode) { when (exitCode) {