Search in sources :

Example 11 with ProjectBuildException

use of org.jetbrains.jps.incremental.ProjectBuildException in project intellij-elixir by KronicDeth.

the class ElixirBuilder method runMix.

private static void runMix(@NotNull ElixirTarget target, @NotNull String elixirPath, @NotNull String mixPath, @Nullable String contentRootPath, @NotNull ElixirCompilerOptions compilerOptions, @NotNull CompileContext context) throws ProjectBuildException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.withWorkDirectory(contentRootPath);
    commandLine.setExePath(elixirPath);
    commandLine.addParameter(mixPath);
    commandLine.addParameter(target.isTests() ? "test" : "compile");
    addCompileOptions(commandLine, compilerOptions);
    Process process;
    try {
        process = commandLine.createProcess();
    } catch (ExecutionException e) {
        throw new ProjectBuildException("Failed to run mix.", e);
    }
    BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
    ProcessAdapter adapter = new ElixirCompilerProcessAdapter(context, MIX_NAME, commandLine.getWorkDirectory().getPath());
    handler.addProcessListener(adapter);
    handler.startNotify();
    handler.waitFor();
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) BaseOSProcessHandler(com.intellij.execution.process.BaseOSProcessHandler)

Example 12 with ProjectBuildException

use of org.jetbrains.jps.incremental.ProjectBuildException in project intellij-elixir by KronicDeth.

the class ElixirBuilder method runElixirc.

private static void runElixirc(ElixirTarget target, CompileContext context, ElixirCompilerOptions compilerOptions, Collection<File> files, File outputDirectory) throws ProjectBuildException {
    GeneralCommandLine commandLine = getElixircCommandLine(target, context, compilerOptions, files, outputDirectory);
    Process process;
    try {
        process = commandLine.createProcess();
    } catch (ExecutionException e) {
        throw new ProjectBuildException("Failed to launch elixir compiler", e);
    }
    BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
    ProcessAdapter adapter = new ElixirCompilerProcessAdapter(context, ElIXIRC_NAME, "");
    handler.addProcessListener(adapter);
    handler.startNotify();
    handler.waitFor();
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) BaseOSProcessHandler(com.intellij.execution.process.BaseOSProcessHandler)

Example 13 with ProjectBuildException

use of org.jetbrains.jps.incremental.ProjectBuildException in project intellij-elixir by KronicDeth.

the class ElixirBuilder method getBuildOutputDirectory.

/*** doBuildWithElixirc releated private methods */
@NotNull
private static File getBuildOutputDirectory(@NotNull JpsModule module, boolean forTests, @NotNull CompileContext context) throws ProjectBuildException {
    JpsJavaExtensionService instance = JpsJavaExtensionService.getInstance();
    File outputDirectory = instance.getOutputDirectory(module, forTests);
    if (outputDirectory == null) {
        String errorMessage = "No output directory for module " + module.getName();
        context.processMessage(new CompilerMessage(ElIXIRC_NAME, BuildMessage.Kind.ERROR, errorMessage));
        throw new ProjectBuildException(errorMessage);
    }
    if (!outputDirectory.exists()) {
        FileUtil.createDirectory(outputDirectory);
    }
    return outputDirectory;
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) JpsJavaExtensionService(org.jetbrains.jps.model.java.JpsJavaExtensionService) CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ProjectBuildException

use of org.jetbrains.jps.incremental.ProjectBuildException in project intellij-elixir by KronicDeth.

the class ElixirBuilder method doBuildWithMix.

private static void doBuildWithMix(ElixirTarget target, CompileContext context, JpsModule module, ElixirCompilerOptions compilerOptions) throws ProjectBuildException, IOException {
    String mixPath = getMixExecutablePath(module.getProject());
    if (mixPath == null) {
        String errorMessage = "Mix path is not set.";
        context.processMessage(new CompilerMessage(MIX_NAME, BuildMessage.Kind.ERROR, errorMessage));
        throw new ProjectBuildException(errorMessage);
    }
    JpsSdk<JpsDummyElement> sdk = ElixirTargetBuilderUtil.getSdk(context, module);
    String elixirPath = JpsElixirSdkType.getScriptInterpreterExecutable(sdk.getHomePath()).getAbsolutePath();
    for (String contentRootUrl : module.getContentRootsList().getUrls()) {
        String contentRootPath = new URL(contentRootUrl).getPath();
        File contentRootDir = new File(contentRootPath);
        File mixConfigFile = new File(contentRootDir, MIX_CONFIG_FILE_NAME);
        if (!mixConfigFile.exists())
            continue;
        runMix(target, elixirPath, mixPath, contentRootPath, compilerOptions, context);
    }
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) File(java.io.File) URL(java.net.URL)

Aggregations

ProjectBuildException (org.jetbrains.jps.incremental.ProjectBuildException)14 File (java.io.File)8 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)7 IOException (java.io.IOException)5 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)5 BaseOSProcessHandler (com.intellij.execution.process.BaseOSProcessHandler)3 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)3 NotNull (org.jetbrains.annotations.NotNull)3 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 URL (java.net.URL)2 JpsProject (org.jetbrains.jps.model.JpsProject)2 Message (com.android.ide.common.blame.Message)1 PatternAwareOutputParser (com.android.ide.common.blame.parser.PatternAwareOutputParser)1 BuildOutputParser (com.android.tools.idea.gradle.output.parser.BuildOutputParser)1 BuildMode (com.android.tools.idea.gradle.util.BuildMode)1 ExecutionException (com.intellij.execution.ExecutionException)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 FlexResourceBuildTarget (com.intellij.flex.build.FlexResourceBuildTarget)1 JpsFlexBuildConfiguration (com.intellij.flex.model.bc.JpsFlexBuildConfiguration)1