diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt
index af6363c60b9..71ca6e225b9 100644
--- a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt
+++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt
@@ -188,6 +188,12 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
messageCollector.report(INFO, "Kotlin JPS plugin version " + KotlinVersion.VERSION, CompilerMessageLocation.NO_LOCATION)
+ val targetsWithoutOutputDir = targets.filter { it.outputDir == null }
+ if (targetsWithoutOutputDir.isNotEmpty()) {
+ messageCollector.report(ERROR, "Output directory not specified for " + targetsWithoutOutputDir.joinToString(), CompilerMessageLocation.NO_LOCATION)
+ return ABORT
+ }
+
val project = projectDescriptor.project
val lookupTracker = getLookupTracker(project)
val incrementalCaches = getIncrementalCaches(chunk, context)
diff --git a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt
index bd6d2403e3b..491b2ab40a6 100644
--- a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt
+++ b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt
@@ -717,6 +717,17 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
assertFalse(File(storageRoot, "targets/java-production/module2/kotlin").exists())
}
+ fun testKotlinProjectWithEmptyProductionOutputDir() {
+ initProject()
+ val result = makeAll()
+ result.assertFailed()
+ result.checkErrors()
+ }
+
+ fun testKotlinProjectWithEmptyTestOutputDir() {
+ doTest()
+ }
+
private fun BuildResult.checkErrors() {
val actualErrors = getMessages(BuildMessage.Kind.ERROR)
.map { it as CompilerMessage }
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/errors.txt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/errors.txt
new file mode 100644
index 00000000000..2c6966278ba
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/errors.txt
@@ -0,0 +1 @@
+Output directory not specified for Module 'kotlinProject' production at line -1, column -1
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.iml
new file mode 100644
index 00000000000..43ffa57d1e2
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.ipr
new file mode 100644
index 00000000000..90747786771
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/kotlinProject.ipr
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/src/foo.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/src/foo.kt
new file mode 100644
index 00000000000..a2c4e958bb5
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/src/foo.kt
@@ -0,0 +1,3 @@
+fun foo() {
+
+}
\ No newline at end of file
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/test/test.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/test/test.kt
new file mode 100644
index 00000000000..839220d1002
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyProductionOutputDir/test/test.kt
@@ -0,0 +1,3 @@
+fun test() {
+
+}
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.iml b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.iml
new file mode 100644
index 00000000000..3e989c372d4
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.ipr b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.ipr
new file mode 100644
index 00000000000..90747786771
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/kotlinProject.ipr
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/src/foo.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/src/foo.kt
new file mode 100644
index 00000000000..a2c4e958bb5
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/src/foo.kt
@@ -0,0 +1,3 @@
+fun foo() {
+
+}
\ No newline at end of file
diff --git a/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/test/test.kt b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/test/test.kt
new file mode 100644
index 00000000000..839220d1002
--- /dev/null
+++ b/jps/jps-plugin/testData/general/KotlinProjectWithEmptyTestOutputDir/test/test.kt
@@ -0,0 +1,3 @@
+fun test() {
+
+}