com.intellij.execution.configurations.RuntimeConfigurationException Java Examples

The following examples show how to use com.intellij.execution.configurations.RuntimeConfigurationException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HaskellRunConfigurationBase.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
protected void requireCabalVersionMinimum(double minimumVersion, @NotNull String errorMessage) throws RuntimeConfigurationException {
    final HaskellBuildSettings buildSettings = HaskellBuildSettings.getInstance(getProject());
    final String cabalPath = buildSettings.getCabalPath();
    if (cabalPath.isEmpty()) {
        throw new RuntimeConfigurationError("Path to cabal is not set.");
    }
    GeneralCommandLine cabalCmdLine = new GeneralCommandLine(cabalPath, "--numeric-version");
    Either<ExecUtil.ExecError, String> result = ExecUtil.readCommandLine(cabalCmdLine);
    if (result.isLeft()) {
        //noinspection ThrowableResultOfMethodCallIgnored
        ExecUtil.ExecError e = EitherUtil.unsafeGetLeft(result);
        NotificationUtil.displaySimpleNotification(
            NotificationType.ERROR, getProject(), "cabal", e.getMessage()
        );
        throw new RuntimeConfigurationError("Failed executing cabal to check its version: " + e.getMessage());
    }
    final String out = EitherUtil.unsafeGetRight(result);
    final Matcher m = EXTRACT_CABAL_VERSION_REGEX.matcher(out);
    if (!m.find()) {
        throw new RuntimeConfigurationError("Could not parse cabal version: '" + out + "'");
    }
    final Double actualVersion = Double.parseDouble(m.group(1));
    if (actualVersion < minimumVersion) {
        throw new RuntimeConfigurationError(errorMessage);
    }
}
 
Example #2
Source File: SSHHandlerTarget.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Authenticates and connects to remote target via ssh protocol
 * @param session
 * @return
 */
@SneakyThrows({RuntimeConfigurationException.class})
private Session connect(Session session) {
    if (!session.isConnected()) {
        session = EmbeddedSSHClient.builder()
                .username(params.getUsername())
                .password(params.getPassword())
                .hostname(params.getHostname())
                .port(params.getSshPort())
                .build().get();
        if (!session.isConnected()) {
            setErrorOnUI(EmbeddedLinuxJVMBundle.getString("ssh.remote.error"));
            throw new RuntimeConfigurationException(EmbeddedLinuxJVMBundle.getString("ssh.remote.error"));
        } else {
            return session;
        }
    }
    return session;
}
 
Example #3
Source File: SSHHandlerTarget.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Runs that java app with the specified command and then takes the console output from target to host machine
 *
 * @param path
 * @param cmd
 * @throws IOException
 */
private void runJavaApp(@NotNull final String path, @NotNull final String cmd) throws IOException, RuntimeConfigurationException {
    consoleView.print(NEW_LINE + EmbeddedLinuxJVMBundle.getString("pi.deployment.build") + NEW_LINE + NEW_LINE, ConsoleViewContentType.SYSTEM_OUTPUT);
    Session session = connect(ssh.get());
    consoleView.setSession(session);
    try {
        ChannelExec channelExec = (ChannelExec) session.openChannel("exec");
        channelExec.setOutputStream(System.out, true);
        channelExec.setErrStream(System.err, true);
        List<String> commands = Arrays.asList(
                String.format("%s kill -9 $(ps -efww | grep \"%s\"| grep -v grep | tr -s \" \"| cut -d\" \" -f2)", params.isRunAsRoot() ? "sudo" : "", params.getMainclass()),
                String.format("cd %s", path),
                String.format("tar -xvf %s.tar", consoleView.getProject().getName()),
                "rm *.tar",
                cmd);
        for (String command : commands) {
            consoleView.print(EmbeddedLinuxJVMBundle.getString("pi.deployment.command") + command + NEW_LINE, ConsoleViewContentType.SYSTEM_OUTPUT);
        }
        channelExec.setCommand(LinuxCommand.builder().commands(commands).build().toString());
        channelExec.connect();
        checkOnProcess(channelExec);
    } catch (JSchException e) {
        setErrorOnUI(e.getMessage());
    }
}
 
Example #4
Source File: SSHHandlerTarget.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Force create directories, if it exists it won't do anything
 *
 * @param path
 * @throws IOException
 * @throws RuntimeConfigurationException
 */
private void forceCreateDirectories(@NotNull final String path) throws IOException, RuntimeConfigurationException {
    Session session = connect(ssh.get());
    try {
        ChannelExec channelExec = (ChannelExec) session.openChannel("exec");
        List<String> commands = Arrays.asList(
                String.format("mkdir -p %s", path),
                String.format("cd %s", path),
                String.format("mkdir -p %s", FileUtilities.CLASSES),
                String.format("mkdir -p %s", FileUtilities.LIB),
                String.format("cd %s", path + FileUtilities.SEPARATOR + FileUtilities.CLASSES),
                "rm -rf *"
        );
        for (String command : commands) {
            consoleView.print(EmbeddedLinuxJVMBundle.getString("pi.deployment.command") + command + NEW_LINE, ConsoleViewContentType.SYSTEM_OUTPUT);
        }
        channelExec.setCommand(LinuxCommand.builder().commands(commands).build().toString());
        channelExec.connect();
        channelExec.disconnect();
    } catch (JSchException e) {
        setErrorOnUI(e.getMessage());
    }
}
 
Example #5
Source File: HaxeApplicationConfiguration.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
  super.checkConfiguration();
  final HaxeApplicationModuleBasedConfiguration configurationModule = getConfigurationModule();
  final Module module = configurationModule.getModule();
  if (module == null) {
    throw new RuntimeConfigurationException(HaxeBundle.message("haxe.run.no.module", getName()));
  }
  final HaxeModuleSettings settings = HaxeModuleSettings.getInstance(module);
  if (settings.isUseHxmlToBuild() && !settings.getCompilationTarget().isNoOutput() && !customFileToLaunch) {
    throw new RuntimeConfigurationException(HaxeBundle.message("haxe.run.select.custom.file"));
  }
  if (settings.isUseNmmlToBuild() && customFileToLaunch) {
    throw new RuntimeConfigurationException(HaxeBundle.message("haxe.run.do.not.select.custom.file"));
  }
  if (settings.isUseNmmlToBuild() && customExecutable) {
    throw new RuntimeConfigurationException(HaxeBundle.message("haxe.run.do.not.select.custom.executable"));
  }
}
 
Example #6
Source File: XQueryRunConfigurationTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
public void testShouldVerifyConfigurationUsingValidators() throws RuntimeConfigurationException {
    configuration.checkConfiguration();

    InOrder inOrder = inOrder(alternativeJreValidator,
            moduleValidator,
            variablesValidator,
            contextItemValidator,
            dataSourceValidator);
    inOrder.verify(alternativeJreValidator).validate(configuration);
    inOrder.verify(moduleValidator).validate(configuration);
    inOrder.verify(variablesValidator).validate(variables);
    inOrder.verify(contextItemValidator).validate(anyBoolean(), anyString(), anyBoolean(), anyString(), anyString());
}
 
Example #7
Source File: EmbeddedLinuxJVMRunnerValidator.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Validates if the Java Settings are Entered Correctly
 *
 * @param configuration
 * @throws RuntimeConfigurationException
 */
public static void checkJavaSettings(EmbeddedLinuxJVMRunConfiguration configuration) throws RuntimeConfigurationException {
    JavaRunConfigurationModule javaRunConfigurationModule = new JavaRunConfigurationModule(configuration.getProject(), false);
    PsiClass psiClass = javaRunConfigurationModule.findClass(configuration.getRunnerParameters().getMainclass());
    if (psiClass == null) {
        throw new RuntimeConfigurationWarning(ExecutionBundle.message("main.method.not.found.in.class.error.message", configuration.getRunnerParameters().getMainclass()));
    }
}
 
Example #8
Source File: SSHHandlerTarget.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Generic SSh Ftp uploader
 *
 * @param deploymentPath the remote location storing the compressed file
 * @param fileToUpload   files to upload
 * @throws IOException
 * @throws RuntimeConfigurationException
 */
public void genericUpload(@NotNull final String deploymentPath, @NotNull final File fileToUpload) throws IOException, RuntimeConfigurationException {
    forceCreateDirectories(deploymentPath);
    Session session = connect(ssh.get());
    try {
        SFTPHandler sftpHandler = new SFTPHandler(consoleView);
        sftpHandler.upload(session, fileToUpload, deploymentPath);
    } catch (Exception e) {
        setErrorOnUI(e.getMessage());
    }
}
 
Example #9
Source File: ClasspathServiceTest.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void givenSameNameSizeAndDateOnlyOutputShouldBePresent() throws JSchException, RuntimeConfigurationException, SftpException, IOException {
    when(jar1Server.getAttrs().getSize()).thenReturn(JAR1_SIZE);
    when(jar2Server.getAttrs().getSize()).thenReturn(JAR2_SIZE);
    when(jar1Server.getAttrs().getMtimeString()).thenReturn(new Date(JAR1_LAST_MODIFIED).toString());
    when(jar2Server.getAttrs().getMtimeString()).thenReturn(new Date(JAR2_LAST_MODIFIED).toString());
    List<File> files = classpathService.invokeFindDeployedJars(hostFiles, target);
    assertEquals(files.size(), 1);
    assertEquals(files.get(0).getName(), output.getName());
}
 
Example #10
Source File: ClasspathServiceTest.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void givenSameNameSizeDifferentDateOutputShouldNotBePresent() throws SftpException, RuntimeConfigurationException, JSchException, IOException {
    when(jar1Server.getAttrs().getSize()).thenReturn(JAR1_SIZE * 10);
    when(jar2Server.getAttrs().getSize()).thenReturn(JAR2_SIZE * 10);
    when(jar1Server.getAttrs().getMtimeString()).thenReturn(new Date(JAR1_LAST_MODIFIED).toString());
    when(jar2Server.getAttrs().getMtimeString()).thenReturn(new Date(JAR2_LAST_MODIFIED).toString());
    List<File> files = classpathService.invokeFindDeployedJars(hostFiles, target);
    assertEquals(files.size(), hostFiles.size());
}
 
Example #11
Source File: XQueryRunConfiguration.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
    alternativeJreValidator.validate(this);
    moduleValidator.validate(this);
    variablesValidator.validate(variables);
    contextItemValidator.validate(contextItemEnabled, contextItemType, contextItemFromEditorEnabled,
            contextItemText, contextItemType);
    dataSourceValidator.validate(dataSourceName);
}
 
Example #12
Source File: DataSourceValidatorTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldThrowAnExceptionIfDataSourceNameNotSet() {
    try {
        validator.validate(null);
        fail();
    } catch (RuntimeConfigurationException e) {
        assertThat(e.getMessage(), is(DATA_SOURCE_MISSING_MESSAGE));
    }
}
 
Example #13
Source File: VariablesValidatorTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldThrowAnExceptionIfVariableWithoutName() {
    variables.setVariables(asList(new XQueryRunVariable()));

    try {
        validator.validate(variables);
        fail();
    } catch (RuntimeConfigurationException e) {
        assertThat(e.getMessage(), is(INCORRECT_VARIABLE_MESSAGE));
    }
}
 
Example #14
Source File: BlazeCommandRunConfigurationCommonState.java    From intellij with Apache License 2.0 5 votes vote down vote up
public void validate(BuildSystem buildSystem) throws RuntimeConfigurationException {
  if (getCommandState().getCommand() == null) {
    throw new RuntimeConfigurationError("You must specify a command.");
  }
  String blazeBinaryString = getBlazeBinaryState().getBlazeBinary();
  if (blazeBinaryString != null && !(new File(blazeBinaryString).exists())) {
    throw new RuntimeConfigurationError(buildSystem.getName() + " binary does not exist");
  }
}
 
Example #15
Source File: VariablesValidatorTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldThrowAnExceptionIfVariableWithoutType() {
    variables.setVariables(asList(new XQueryRunVariable("name", null, null, null, false)));

    try {
        validator.validate(variables);
        fail();
    } catch (RuntimeConfigurationException e) {
        assertThat(e.getMessage(), is(INCORRECT_VARIABLE_MESSAGE));
    }
}
 
Example #16
Source File: ClasspathServiceTest.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void givenSameNameDateDifferentSizeOutputShouldNotBePresent() throws SftpException, RuntimeConfigurationException, JSchException, IOException {
    when(jar1Server.getAttrs().getSize()).thenReturn(JAR1_SIZE);
    when(jar2Server.getAttrs().getSize()).thenReturn(JAR2_SIZE);
    when(jar1Server.getAttrs().getMtimeString()).thenReturn(new Date(JAR1_LAST_MODIFIED * 2).toString());
    when(jar2Server.getAttrs().getMtimeString()).thenReturn(new Date(JAR2_LAST_MODIFIED * 2).toString());
    List<File> files = classpathService.invokeFindDeployedJars(hostFiles, target);
    assertEquals(files.size(), hostFiles.size());
}
 
Example #17
Source File: ContextItemValidatorTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldThrowAnExceptionIfContextItemWithoutType() {
    try {
        validator.validate(true, null, false, null, null);
        fail();
    } catch (RuntimeConfigurationException e) {
        assertThat(e.getMessage(), is(CONTEXT_ITEM_TYPE_MISSING_MESSAGE));
    }
}
 
Example #18
Source File: ContextItemValidatorTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldThrowAnExceptionIfContextItemWithoutFile() {

    try {
        validator.validate(true, "xs:string", false, null, null);
        fail();
    } catch (RuntimeConfigurationException e) {
        assertThat(e.getMessage(), is(CONTEXT_ITEM_FILE_MISSING_MESSAGE));
    }
}
 
Example #19
Source File: ClasspathServiceTest.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void givenSameNameDateDifferentSizeJustForOneOutputShouldNotBePresent() throws SftpException, RuntimeConfigurationException, JSchException, IOException {
    when(jar1Server.getAttrs().getSize()).thenReturn(JAR1_SIZE);
    when(jar2Server.getAttrs().getSize()).thenReturn(JAR2_SIZE);
    when(jar1Server.getAttrs().getMtimeString()).thenReturn(new Date(JAR1_LAST_MODIFIED).toString());
    when(jar2Server.getAttrs().getMtimeString()).thenReturn(new Date(JAR2_LAST_MODIFIED * 2).toString());
    List<File> files = classpathService.invokeFindDeployedJars(hostFiles, target);
    assertEquals(files.size(), hostFiles.size() - 1);
}
 
Example #20
Source File: BlazeAndroidRunConfigurationValidationUtil.java    From intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the top error, as determined by {@link ValidationError#compareTo(Object)}. If it is
 * fatal, it is thrown as a {@link RuntimeConfigurationError}; otherwise it is thrown as a {@link
 * RuntimeConfigurationWarning}. If no errors exist, nothing is thrown.
 */
public static void throwTopConfigurationError(List<ValidationError> errors)
    throws RuntimeConfigurationException {
  if (errors.isEmpty()) {
    return;
  }
  // TODO: Do something with the extra error information? Error count?
  ValidationError topError = Ordering.natural().max(errors);
  if (topError.isFatal()) {
    throw new RuntimeConfigurationError(topError.getMessage(), topError.getQuickfix());
  }
  throw new RuntimeConfigurationWarning(topError.getMessage(), topError.getQuickfix());
}
 
Example #21
Source File: GaugeRerunFailedAction.java    From Intellij-Plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
}
 
Example #22
Source File: PantsJUnitRunnerAndConfigurationSettings.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void checkSettings(@Nullable Executor executor) throws RuntimeConfigurationException {
  myRunConfiguration.checkConfiguration();
}
 
Example #23
Source File: PantsJUnitRunnerAndConfigurationSettings.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void checkSettings() throws RuntimeConfigurationException {
  myRunConfiguration.checkConfiguration();
}
 
Example #24
Source File: HaskellRunConfigurationBase.java    From intellij-haskforce with Apache License 2.0 4 votes vote down vote up
protected void requireCabal1_18() throws RuntimeConfigurationException {
    requireCabalVersionMinimum(1.18, "Run configurations require cabal 1.18 or higher.");
}
 
Example #25
Source File: HaskellTestRunConfiguration.java    From intellij-haskforce with Apache License 2.0 4 votes vote down vote up
/**
 * If the user is not using cabal 1.18 or higher, an error is displayed in the run configuration dialog.
 */
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
    requireCabal1_18();
}
 
Example #26
Source File: SSHHandlerTargetTest.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void nullFile() throws IOException, RuntimeConfigurationException {
    target.genericUpload("/home", null);
}
 
Example #27
Source File: ModuleValidator.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
public void validate(XQueryRunConfiguration xQueryRunConfiguration) throws RuntimeConfigurationException {
    final RunConfigurationModule configurationModule = xQueryRunConfiguration.getConfigurationModule();
    ProgramParametersUtil.checkWorkingDirectoryExist(xQueryRunConfiguration, xQueryRunConfiguration.getProject(), configurationModule.getModule());
}
 
Example #28
Source File: VariablesValidatorTest.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldNotThrowAnExceptionIfVariableIsOk() throws RuntimeConfigurationException {
    variables.setVariables(asList(variable1));

    validator.validate(variables);
}
 
Example #29
Source File: DeployToServerRunConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
}
 
Example #30
Source File: LocalServerRunConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
}