Package com.intellij.execution

Examples of com.intellij.execution.CantRunException


            return ApplicationManager.getApplication().runReadAction(new Computable<GeneralCommandLine>() {
                public GeneralCommandLine compute() {
                    try {
                        HaskellParameters parameters = getHaskellParameters();
                        if (parameters == null) {
                            throw new CantRunException("Configuration parameters not specified");
                        }
                        Sdk ghc = parameters.getGhc();
                        if (ghc == null) {
                            throw new CantRunException(NO_GHC);
                        }

                        SdkTypeId sdkTypeId = ghc.getSdkType();
                        if (!(sdkTypeId instanceof HaskellSdkType)) {
                            throw new CantRunException(NO_GHC);
                        }

                        String exePath = ghc.getHomePath() + "/bin/" + GHCUtil.getExeName("runghc"); // todo
                        if (!new File(exePath).isFile()) {
                            throw new CantRunException("Cannot find runghc executable");
                        }
                        String mainFile = parameters.getMainFile();
                        if (mainFile == null) {
                            throw new CantRunException("Main module is not specified");
                        }

                        GeneralCommandLine commandLine = new GeneralCommandLine();
                        commandLine.setExePath(exePath);
                        commandLine.setCharset(HaskellFileType.HASKELL_CHARSET);
View Full Code Here


    }
    else {
      myWorkingDir = new File(myRunConfiguration.getWorkingDir());
    }
    if (!myWorkingDir.isDirectory() && !myWorkingDir.mkdirs()) {
      throw new CantRunException("Cannot create work directory '" + myWorkingDir.getPath() + "'");
    }
    params.setWorkingDirectory(myWorkingDir);

    // only add JDK classes to the classpath, the rest is to be provided by bundles
    params.configureByProject(myRunConfiguration.getProject(), JavaParameters.JDK_ONLY, jdkForRun);

    // class path

    Collection<SelectedBundle> systemBundles = myInstanceManager.getFrameworkBundles(myInstance, FrameworkBundleType.SYSTEM);
    if (systemBundles.isEmpty()) {
      throw new CantRunException("Libraries required to start the framework not found - please check the installation");
    }
    for (SelectedBundle bundle : systemBundles) {
      String path = bundle.getBundlePath();
      assert path != null : bundle;
      params.getClassPath().add(path);
    }

    if (GenericRunProperties.isStartConsole(myAdditionalProperties)) {
      Collection<SelectedBundle> shellBundles = myInstanceManager.getFrameworkBundles(myInstance, FrameworkBundleType.SHELL);
      if (shellBundles.isEmpty()) {
        throw new CantRunException("Console requested but no shell bundles can be found - please check the installation");
      }
      List<SelectedBundle> allBundles = ContainerUtil.newArrayList(shellBundles);
      allBundles.addAll(myBundles);
      myBundles = allBundles;
    }
View Full Code Here

    super(environment);
    myRunConfiguration = configuration;

    FrameworkInstanceDefinition instance = myRunConfiguration.getInstanceToUse();
    if (instance == null) {
      throw new CantRunException("Incorrect OSGi run configuration: framework not set");
    }
    FrameworkIntegrator integrator = FrameworkIntegratorRegistry.getInstance().findIntegratorByInstanceDefinition(instance);
    if (integrator == null) {
      throw new CantRunException("Internal error: missing integrator for " + instance);
    }
    myRunner = integrator.createFrameworkRunner();
  }
View Full Code Here

            if (selectedBundle.isModule()) {
              // use the output jar name if it is a module
              String name = selectedBundle.getName();
              Module module = moduleManager.findModuleByName(name);
              if (module == null) {
                throw new CantRunException("Module '" + name + "' no longer exists. Please check your run configuration.");
              }
              OsmorcFacet facet = OsmorcFacet.getInstance(module);
              if (facet == null) {
                throw new CantRunException("Module '" + name + "' has no OSGi facet. Please check your run configuration.");
              }
              selectedBundle.setBundlePath(facet.getConfiguration().getJarFileLocation());
              selectedBundles.add(selectedBundle);
              // add all the library dependencies of the bundle
              List<String> paths = new BundleCompiler().bundlifyLibraries(module, progressIndicator);
              for (String path : paths) {
                selectedBundles.add(new SelectedBundle(SelectedBundle.BundleType.PlainLibrary, "Dependency", path));
              }
            }
            else {
              if (selectedBundles.contains(selectedBundle)) {
                // if the user selected a dependency as runnable library, we need to replace the dependency with
                // the runnable library part
                selectedBundles.remove(selectedBundle);
              }
              selectedBundles.add(selectedBundle);
            }
          }

          // filter out bundles which have the same symbolic name
          Map<String, SelectedBundle> filteredBundles = new HashMap<String, SelectedBundle>();
          for (SelectedBundle selectedBundle : selectedBundles) {
            String path = selectedBundle.getBundlePath();
            if (path != null) {
              String name = CachingBundleInfoProvider.getBundleSymbolicName(path);
              String version = CachingBundleInfoProvider.getBundleVersion(path);
              String key = name + version;
              if (!filteredBundles.containsKey(key)) {
                filteredBundles.put(key, selectedBundle);
              }
            }
          }

          List<SelectedBundle> sortedBundles = ContainerUtil.newArrayList(filteredBundles.values());
          Collections.sort(sortedBundles, START_LEVEL_COMPARATOR);
          result.set(sortedBundles);
        }
        catch (CantRunException e) {
          error.set(e);
        }
        catch (OsgiBuildException e) {
          LOG.warn(e);
          error.set(new CantRunException(e.getMessage()));
        }
        catch (Throwable t) {
          LOG.error(t);
          error.set(new CantRunException("Internal error: " + t.getMessage()));
        }
        finally {
          token.finish();
        }
      }
View Full Code Here

    public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner)
            throws ExecutionException {

        Sdk sdk = GoSdkUtil.getGoogleGoSdkForProject(project);
        if ( sdk == null ) {
            throw new CantRunException("No Go Sdk defined for this project");
        }

        final GoSdkData sdkData = (GoSdkData)sdk.getSdkAdditionalData();
        if ( sdkData == null ) {
            throw new CantRunException("No Go Sdk defined for this project");
        }

        String goExecName = sdkData.GO_BIN_PATH;
        if (goExecName == null) {
            throw new CantRunException("Could not determine the go binary path");
        }

        String projectDir = project.getBasePath();

        if (projectDir == null) {
            throw new CantRunException("Could not retrieve the project directory");
        }

        GoProjectSettings.GoProjectSettingsBean settings = GoProjectSettings.getInstance(project).getState();
        Map<String,String> sysEnv = GoSdkUtil.getExtendedSysEnv(sdkData, projectDir, m_configuration.envVars, settings.prependGoPath, settings.useGoPath);

        GoToolWindow toolWindow = GoToolWindow.getInstance(project);
        toolWindow.setTitle(TITLE);

        // Build and run
        String execName;
        if (m_configuration.runExecutableName != null && m_configuration.runExecutableName.trim().length() > 0) {
            execName = m_configuration.goOutputDir.concat("/").concat(m_configuration.runExecutableName);
        }
        else {
            execName = m_configuration.goOutputDir.concat("/").concat(m_configuration.getName());
        }

        if (execName.endsWith(".go")) {
            execName = execName.substring(0, execName.length() - 3);
        }

        if (GoSdkUtil.isHostOsWindows()) {
            execName = execName.concat(".exe");
        }

        try {
            String[] goEnv = GoSdkUtil.convertEnvMapToArray(sysEnv);

            String scriptOrPackage;
            if (m_configuration.runPackage) {
                scriptOrPackage = new java.io.File(m_configuration.getProject().getBaseDir().getPath().concat("/src")).toURI().relativize(new java.io.File(m_configuration.packageDir).toURI()).getPath();
            }
            else {
                scriptOrPackage = m_configuration.scriptName;
            }
            String[] command = GoSdkUtil.computeGoBuildCommand(goExecName, m_configuration.debugBuilderArguments, execName, scriptOrPackage);

            Runtime rt = Runtime.getRuntime();
            Process proc = rt.exec(command, goEnv, new File(projectDir));
            OSProcessHandler handler = new OSProcessHandler(proc, null);
            toolWindow.attachConsoleViewToProcess(handler);
            toolWindow.printNormalMessage(String.format("%s%n", StringUtil.join(command, " ")));
            toolWindow.showAndCreate(project);
            handler.startNotify();

            if (proc.waitFor() == 0) {
                VirtualFileManager.getInstance().syncRefresh();

                toolWindow.printNormalMessage(String.format("%nFinished building project %s%n", execName));
            } else {
                toolWindow.printErrorMessage(String.format("%nCould't build project %s%n", execName));
                throw new Exception("Unable to build executable file");
            }


        } catch (Exception e) {
            e.printStackTrace();
            Messages.showErrorDialog(String.format("Error while processing %s build command: %s.", goExecName, e.getMessage()), "Error on Google Go Plugin");
            throw new CantRunException(String.format("Error while processing %s build command: %s.", goExecName, e.getMessage()));
        }


        ProcessHandler processHandler = new DefaultDebugProcessHandler();
View Full Code Here

    @NotNull
    @Override
    protected ProcessHandler startProcess() throws ExecutionException {
        Sdk sdk = GoSdkUtil.getGoogleGoSdkForProject(m_project);
        if ( sdk == null ) {
            throw new CantRunException("No Go Sdk defined for this project");
        }

        final GoSdkData sdkData = (GoSdkData)sdk.getSdkAdditionalData();
        if ( sdkData == null ) {
            throw new CantRunException("No Go Sdk defined for this project");
        }

        String goExecName = GoSdkUtil.getGoExecName(sdk);
        if (goExecName == null) {
            throw new CantRunException("Could not determine the go binary path");
        }

        String projectDir = m_project.getBasePath();

        if (projectDir == null) {
            throw new CantRunException("Could not retrieve the project directory");
        }

        GoProjectSettings.GoProjectSettingsBean settings = GoProjectSettings.getInstance(m_project).getState();
        Map<String,String> sysEnv = GoSdkUtil.getExtendedSysEnv(sdkData, projectDir, m_configuration.envVars, settings.prependGoPath, settings.useGoPath);

        GoToolWindow toolWindow = GoToolWindow.getInstance(m_project);
        toolWindow.setTitle(TITLE);

        if (!m_configuration.goBuildBeforeRun && !m_configuration.runPackage) {
            // Just run
            GeneralCommandLine commandLine = new GeneralCommandLine();

            commandLine.setExePath(goExecName);
            commandLine.addParameter("run");
            if (m_configuration.runBuilderArguments != null && m_configuration.runBuilderArguments.trim().length() > 0) {
                commandLine.getParametersList().addParametersString(m_configuration.runBuilderArguments);
            }

            commandLine.addParameter(m_configuration.scriptName);
            if (m_configuration.scriptArguments != null && m_configuration.scriptArguments.trim().length() > 0) {
                commandLine.getParametersList().addParametersString(m_configuration.scriptArguments);
            }

            commandLine.getEnvironment().putAll(sysEnv);
            commandLine.withWorkDirectory(m_configuration.workingDir);

            return GoApplicationProcessHandler.runCommandLine(commandLine);
        }

        // Build and run
        String execName;
        if (m_configuration.runExecutableName != null && m_configuration.runExecutableName.trim().length() > 0) {
            execName = m_configuration.goOutputDir.concat("/").concat(m_configuration.runExecutableName);
        }
        else {
            execName = m_configuration.goOutputDir.concat("/").concat(m_configuration.getName());
        }

        if (execName.endsWith(".go")) {
            execName = execName.substring(0, execName.length() - 3);
        }

        if (GoSdkUtil.isHostOsWindows()) {
            if (!execName.endsWith(".exe")) {
                execName = execName.concat(".exe");
            }
        }

        (new File(execName)).delete();

        try {
            String[] goEnv = GoSdkUtil.convertEnvMapToArray(sysEnv);

            String scriptOrPackage;
            if (m_configuration.runPackage) {
                scriptOrPackage = new java.io.File(m_configuration.getProject().getBaseDir().getPath().concat("/src")).toURI().relativize(new java.io.File(m_configuration.packageDir).toURI()).getPath();
            }
            else {
                scriptOrPackage = m_configuration.scriptName;
            }
            String[] command = GoSdkUtil.computeGoBuildCommand(goExecName, m_configuration.runBuilderArguments, execName, scriptOrPackage);

            Runtime rt = Runtime.getRuntime();
            Process proc = rt.exec(command, goEnv, new File(projectDir));
            OSProcessHandler handler = new OSProcessHandler(proc, null);
            toolWindow.attachConsoleViewToProcess(handler);
            toolWindow.printNormalMessage(String.format("%s%n", StringUtil.join(command, " ")));
            toolWindow.showAndCreate(m_project);
            handler.startNotify();

            if (proc.waitFor() == 0) {
                VirtualFileManager.getInstance().syncRefresh();
                toolWindow.printNormalMessage(String.format("%nFinished building project %s%n", execName));
            } else {
                toolWindow.printErrorMessage(String.format("%nCould't build project %s%n", execName));
                throw new CantRunException(String.format("Error while processing %s build command.", goExecName));
            }
        } catch (Exception e) {
            throw new CantRunException(String.format("Error while processing %s build command.", goExecName));
        }

        // Now run the build
        GeneralCommandLine commandLine = new GeneralCommandLine();
View Full Code Here

        GoProjectSettings.getInstance(module.getProject()).loadState(settings);

        try {
            Sdk sdk = GoSdkUtil.getGoogleGoSdkForProject(module.getProject());
            if ( sdk == null ) {
                throw new CantRunException("No Go Sdk defined for this project");
            }
            final GoSdkData sdkData = (GoSdkData)sdk.getSdkAdditionalData();
            if ( sdkData == null ) {
                throw new CantRunException("No Go Sdk defined for this project");
            }
            final String goExecName = GoSdkUtil.getGoExecName(sdk);
            if (goExecName == null) {
                return;
            }
            final String projectDir = module.getProject().getBasePath();
            if (projectDir == null) {
                throw new CantRunException("Could not retrieve the project directory");
            }
            final GoToolWindow toolWindow = GoToolWindow.getInstance(module.getProject());
            toolWindow.setTitle(TITLE);
            toolWindow.showAndCreate(module.getProject());
View Full Code Here

            @NotNull
            @Override
            protected OSProcessHandler startProcess() throws ExecutionException {
                Sdk sdk = GoSdkUtil.getGoogleGAESdkForProject(getProject());
                if ( sdk == null ) {
                    throw new CantRunException("No Go AppEngine Sdk defined for this project");
                }

                final GoAppEngineSdkData sdkData = (GoAppEngineSdkData)sdk.getSdkAdditionalData();
                if ( sdkData == null ) {
                    throw new CantRunException("No Go AppEngine Sdk defined for this project");
                }

                String goExecName = sdkData.SDK_HOME_PATH + File.separator + "goapp";

                if (GoSdkUtil.isHostOsWindows()) {
                    goExecName = goExecName.concat(".bat");
                }

                String projectDir = project.getBasePath();

                if (projectDir == null) {
                    throw new CantRunException("Could not retrieve the project directory");
                }

                Map<String, String> sysEnv = GoSdkUtil.getExtendedSysEnv(sdkData, "", envVars);
                GeneralCommandLine commandLine = new GeneralCommandLine();
View Full Code Here

  public Process createProcess() throws ExecutionException {
    checkWorkingDirectory();
    try {
      final String[] commands = getCommands();
      if(commands[0] == null) throw new CantRunException(ExecutionBundle.message("run.configuration.error.executable.not.specified"));

      return myWorkDirectory != null
             ? Runtime.getRuntime().exec(commands, getEnvParamsArray(), myWorkDirectory)
             : Runtime.getRuntime().exec(commands, getEnvParamsArray());
    }
View Full Code Here

        public GeneralCommandLine compute() {
          try {
            final GeneralCommandLine commandLine = new GeneralCommandLine();
            final ProjectJdk jdk = javaParameters.getJdk();
            if(jdk == null) {
              throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
            }

            final String exePath = jdk.getVMExecutablePath();
            if(exePath == null) {
              throw new CantRunException(ExecutionBundle.message("run.configuration.cannot.find.vm.executable"));
            }
            commandLine.setExePath(exePath);
            ParametersList parametersList = javaParameters.getVMParametersList();
            commandLine.addParameters(parametersList.getList());
            if (!parametersList.hasProperty("file.encoding")) {
              Charset charset = javaParameters.getCharset();
              if (charset == null) charset = CharsetToolkit.getIDEOptionsCharset();
              if (charset == null) charset = CharsetToolkit.getDefaultSystemCharset();
              commandLine.setCharset(charset);
            }

            if(!parametersList.hasParameter("-classpath") && !parametersList.hasParameter("-cp")){
              commandLine.addParameter("-classpath");
              commandLine.addParameter(javaParameters.getClassPath().getPathsString());
            }

            String mainClass = javaParameters.getMainClass();
            if(mainClass == null) throw new CantRunException(ExecutionBundle.message("main.class.is.not.specified.error.message"));
            commandLine.addParameter(mainClass);
            commandLine.addParameters(javaParameters.getProgramParametersList().getList());
            commandLine.setWorkDirectory(javaParameters.getWorkingDirectory());

            final Map<String, String> env = javaParameters.getEnv();
View Full Code Here

TOP

Related Classes of com.intellij.execution.CantRunException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.