diff --git a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerEnvironment.java b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerEnvironment.java index c883ae5ea7c..a2e19be1a7d 100644 --- a/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerEnvironment.java +++ b/ide-compiler-runner/src/org/jetbrains/jet/compiler/runner/CompilerEnvironment.java @@ -24,8 +24,6 @@ import org.jetbrains.jet.preloading.ClassCondition; import org.jetbrains.jet.utils.KotlinPaths; import org.jetbrains.jet.utils.PathUtil; -import java.io.File; - import static org.jetbrains.jet.cli.common.messages.CompilerMessageLocation.NO_LOCATION; import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.ERROR; @@ -34,19 +32,16 @@ public final class CompilerEnvironment { @NotNull public static CompilerEnvironment getEnvironmentFor( @NotNull KotlinPaths kotlinPaths, - @Nullable File outputDir, @Nullable ClassLoader parentClassLoader, @NotNull ClassCondition classesToLoadByParent, @NotNull Services compilerServices ) { - return new CompilerEnvironment(kotlinPaths, outputDir, parentClassLoader, classesToLoadByParent, compilerServices); + return new CompilerEnvironment(kotlinPaths, parentClassLoader, classesToLoadByParent, compilerServices); } @NotNull private final KotlinPaths kotlinPaths; @Nullable - private final File output; - @Nullable private final ClassLoader parentClassLoader; @NotNull private final ClassCondition classesToLoadByParent; @@ -55,20 +50,18 @@ public final class CompilerEnvironment { private CompilerEnvironment( @NotNull KotlinPaths kotlinPaths, - @Nullable File output, @Nullable ClassLoader parentClassLoader, @NotNull ClassCondition classesToLoadByParent, @NotNull Services services ) { this.kotlinPaths = kotlinPaths; - this.output = output; this.parentClassLoader = parentClassLoader; this.classesToLoadByParent = classesToLoadByParent; this.services = services; } public boolean success() { - return kotlinPaths.getHomePath().exists() && output != null; + return kotlinPaths.getHomePath().exists(); } @NotNull @@ -76,12 +69,6 @@ public final class CompilerEnvironment { return kotlinPaths; } - @NotNull - public File getOutput() { - assert output != null; - return output; - } - @Nullable public ClassLoader getParentClassLoader() { return parentClassLoader; @@ -93,9 +80,6 @@ public final class CompilerEnvironment { } public void reportErrorsTo(@NotNull MessageCollector messageCollector) { - if (output == null) { - messageCollector.report(ERROR, "[Internal Error] No output directory", NO_LOCATION); - } if (!kotlinPaths.getHomePath().exists()) { messageCollector.report(ERROR, "Cannot find kotlinc home: " + kotlinPaths.getHomePath() + ". Make sure plugin is properly installed, " + "or specify " + PathUtil.JPS_KOTLIN_HOME_PROPERTY + " system property", NO_LOCATION); diff --git a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.kt b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.kt index fd8e782ee22..8dff4f07311 100644 --- a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilder.kt @@ -87,8 +87,6 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR val representativeTarget = chunk.representativeTarget() - val outputDir = representativeTarget.getOutputDir() - val dataManager = context.getProjectDescriptor().dataManager val incrementalCaches = chunk.getTargets().keysToMap { dataManager.getStorage(it, IncrementalCacheStorageProvider) } @@ -114,7 +112,6 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR val environment = CompilerEnvironment.getEnvironmentFor( PathUtil.getKotlinPathsForJpsPluginOrJpsTests(), - outputDir, javaClass.getClassLoader(), { className -> className!!.startsWith("org.jetbrains.jet.lang.resolve.kotlin.incremental.cache.") @@ -128,8 +125,6 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR return ABORT } - assert(outputDir != null, "CompilerEnvironment must have checked for outputDir to be not null, but it didn't") - val outputItemCollector = OutputItemsCollectorImpl() val project = representativeTarget.getModule().getProject()!! @@ -162,6 +157,8 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR return NOTHING_DONE } + val outputDir = KotlinBuilderModuleScriptGenerator.getOutputDirSafe(representativeTarget) + val outputFile = File(outputDir, representativeTarget.getModule().getName() + ".js") val libraryFiles = JpsJsModuleUtils.getLibraryFilesAndDependencies(representativeTarget) val k2JsArguments = JpsKotlinCompilerSettings.getK2JsCompilerArguments(project) diff --git a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilderModuleScriptGenerator.java b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilderModuleScriptGenerator.java index 8a12efc8468..4bf4e25a006 100644 --- a/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilderModuleScriptGenerator.java +++ b/jps-plugin/src/org/jetbrains/jet/jps/build/KotlinBuilderModuleScriptGenerator.java @@ -31,6 +31,7 @@ import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor; import org.jetbrains.jps.builders.logging.ProjectBuilderLogger; import org.jetbrains.jps.incremental.CompileContext; import org.jetbrains.jps.incremental.ModuleBuildTarget; +import org.jetbrains.jps.incremental.ProjectBuildException; import org.jetbrains.jps.model.java.JpsAnnotationRootType; import org.jetbrains.jps.model.java.JpsJavaSdkType; import org.jetbrains.jps.model.library.JpsLibrary; @@ -60,7 +61,7 @@ public class KotlinBuilderModuleScriptGenerator { MultiMap sourceFiles, // ignored for non-incremental compilation boolean hasRemovedFiles ) - throws IOException + throws IOException, ProjectBuildException { KotlinModuleDescriptionBuilder builder = FACTORY.create(); @@ -68,11 +69,11 @@ public class KotlinBuilderModuleScriptGenerator { Set outputDirs = new HashSet(); for (ModuleBuildTarget target : chunk.getTargets()) { - outputDirs.add(getOutputDir(target)); + outputDirs.add(getOutputDirSafe(target)); } ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger(); for (ModuleBuildTarget target : chunk.getTargets()) { - File outputDir = getOutputDir(target); + File outputDir = getOutputDirSafe(target); List moduleSources = new ArrayList( IncrementalCompilation.ENABLED @@ -108,10 +109,10 @@ public class KotlinBuilderModuleScriptGenerator { } @NotNull - private static File getOutputDir(@NotNull ModuleBuildTarget target) { + public static File getOutputDirSafe(@NotNull ModuleBuildTarget target) throws ProjectBuildException { File outputDir = target.getOutputDir(); if (outputDir == null) { - throw new IllegalStateException("No output directory found for " + target); + throw new ProjectBuildException("No output directory found for " + target); } return outputDir; }