KT-3056 Kotlin: Cannot find kotlinc home. Make sure plugin is properly installed

#KT-3056 Fixed
This commit is contained in:
Andrey Breslav
2012-11-21 14:09:39 +04:00
parent 19e283a333
commit 4ee76a6649
4 changed files with 23 additions and 3 deletions
@@ -67,6 +67,20 @@ public class PathUtil {
return null;
}
public static File getCompilerPathForJpsPlugin() {
File plugin_jar_path = new File(getJarPathForClass(PathUtil.class));
if (!plugin_jar_path.exists()) return null;
if (plugin_jar_path.getName().equals("kotlin-jps-plugin.jar")) {
File pluginHome = plugin_jar_path.getParentFile().getParentFile().getParentFile();
File answer = new File(pluginHome, "kotlinc");
return answer.exists() ? answer : null;
}
return null;
}
@Nullable
public static File getDefaultRuntimePath() {
return getFilePackedIntoLib("kotlin-runtime.jar");
@@ -32,13 +32,17 @@ import static org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity.ERRO
public final class CompilerEnvironment {
@NotNull
public static CompilerEnvironment getEnvironmentFor(boolean tests, File mainOutput, File outputDirectoryForTests) {
public static CompilerEnvironment getEnvironmentFor(boolean tests, @Nullable File mainOutput, @Nullable File outputDirectoryForTests) {
final File outputDir = tests ? outputDirectoryForTests : mainOutput;
return getEnvironmentFor(outputDir);
}
public static CompilerEnvironment getEnvironmentFor(File outputDir) {
public static CompilerEnvironment getEnvironmentFor(@Nullable File outputDir) {
File kotlinHome = PathUtil.getDefaultCompilerPath();
return getEnvironmentFor(kotlinHome, outputDir);
}
public static CompilerEnvironment getEnvironmentFor(@Nullable File kotlinHome, @Nullable File outputDir) {
return new CompilerEnvironment(kotlinHome, outputDir);
}
+1
View File
@@ -10,6 +10,7 @@
<orderEntry type="library" name="idea-full" level="project" />
<orderEntry type="module" module-name="ide-compiler-runner" />
<orderEntry type="module" module-name="cli-common" />
<orderEntry type="module" module-name="util" />
</component>
</module>
@@ -22,6 +22,7 @@ import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
import org.jetbrains.jet.cli.common.messages.MessageCollector;
import org.jetbrains.jet.compiler.runner.*;
import org.jetbrains.jet.utils.PathUtil;
import org.jetbrains.jps.ModuleChunk;
import org.jetbrains.jps.builders.ChunkBuildOutputConsumer;
import org.jetbrains.jps.builders.DirtyFilesHolder;
@@ -83,7 +84,7 @@ public class KotlinBuilder extends ModuleLevelBuilder {
File outputDir = representativeTarget.getOutputDir();
CompilerEnvironment environment = CompilerEnvironment.getEnvironmentFor(outputDir);
CompilerEnvironment environment = CompilerEnvironment.getEnvironmentFor(PathUtil.getCompilerPathForJpsPlugin(), outputDir);
if (!environment.success()) {
environment.reportErrorsTo(messageCollector);
return ExitCode.ABORT;