com.intellij.execution.CantRunException Java Examples

The following examples show how to use com.intellij.execution.CantRunException. 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: XQueryRunnerClasspathEntryGenerator.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
public String generateRunnerClasspathEntries(XQueryRunConfiguration configuration) throws CantRunException {
    XQueryDataSourceConfiguration dataSourceConfiguration = getDataSourceConfiguration(configuration);
    validate(dataSourceConfiguration);
    List<String> pluginJarsEntries = new ArrayList<String>();
    pluginJarsEntries.add(INTELLIJ_XQUERY_RT_JAR);
    pluginJarsEntries.add(DBGP_INTERFACES_JAR);
    pluginJarsEntries.add(NETTY);
    addXqjApiJarsIfNeeded(dataSourceConfiguration, pluginJarsEntries);
    if (!dataSourceConfiguration.USER_DEFINED_LIBRARY_ENABLED) {
        pluginJarsEntries.addAll(dataSourceConfiguration.TYPE.getClasspathEntries());
    }
    Set<String> classPathEntries = getPluginInternalJarEntries(getPluginPath(), pluginJarsEntries);
    if (dataSourceConfiguration.USER_DEFINED_LIBRARY_ENABLED) {
        classPathEntries.addAll(dataSourceConfiguration.USER_DEFINED_LIBRARY_PATHS);
    }
    return separateEntriesWithPathSeparator(classPathEntries);
}
 
Example #2
Source File: XQueryRunnerClasspathEntryGenerator.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private File getClasspathEntryFileIfExists(File pluginPath, String jarName) throws CantRunException {
    File libraryDirectory = new File(pluginPath, "lib");
    File[] files = libraryDirectory.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return name.matches(jarName);
        }
    });
    if (files.length > 1) {
        throw new CantRunException("There should be just one matching library for " + jarName + ", found: " + files.length);
    }
    File rtJarFile = files.length == 1 ? files[0] : new File(libraryDirectory, jarName);
    if (rtJarFile.exists()) return rtJarFile;
    File classesDirectory = new File(pluginPath, "classes");
    if (classesDirectory.exists()) return classesDirectory;
    if (isTestRun(pluginPath)) {
        return pluginPath;
    } else {
        throw new CantRunException("Runtime classes not found");
    }
}
 
Example #3
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private Sdk getValidJdkToRunModule(final Module module) throws CantRunException {
    Sdk jdk = getJdkToRunModule(module);
    String currentRunningJavaHome = getCurrentRunningJavaHome();
    if (jdk == null) {
        if (currentRunningJavaHome != null) {
            jdk = createAlternativeJdk(currentRunningJavaHome);
        } else {
            throw CantRunException.noJdkForModule(module);
        }
    }
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null || !homeDirectory.isValid()) {
        throw CantRunException.jdkMisconfigured(jdk, module);
    }
    return jdk;
}
 
Example #4
Source File: FreeRunConfiguration.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@Override
protected ProcessHandler startProcess() throws ExecutionException {
    if (!FreelineUtil.hadInitFreeline(getProject())) {
        throw new CantRunException("Not yet initialized freeline code");
    }
    // here just run one command: python freeline.py
    GeneralCommandLine commandLine = new GeneralCommandLine();
    ExecutionEnvironment environment = getEnvironment();
    commandLine.setWorkDirectory(environment.getProject().getBasePath());
    commandLine.setExePath("python");
    commandLine.addParameters("freeline.py");
    return new OSProcessHandler(commandLine);
}
 
Example #5
Source File: MongoRunConfiguration.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final VirtualFile script = getScriptPath();
    if (script == null) {
        throw new CantRunException("Cannot find script " + scriptPath);
    }

    final MongoCommandLineState state = new MongoCommandLineState(this, env);
    state.setConsoleBuilder(TextConsoleBuilderFactory.getInstance().createBuilder(getProject()));
    return state;
}
 
Example #6
Source File: XQueryRunnerClasspathEntryGenerator.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private Set<String> getPluginInternalJarEntries(File pluginPath, List<String> entryList) throws CantRunException {
    Set<String> entrySet = new LinkedHashSet<String>();
    for (String entry : entryList) {
        entrySet.add(getClasspathEntryFileIfExists(pluginPath, entry).getAbsolutePath());
    }
    return entrySet;
}
 
Example #7
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private void configureModule(final RunConfigurationModule runConfigurationModule,
                             final SimpleJavaParameters parameters,
                             @Nullable String jreHome) throws CantRunException {
    Module module = runConfigurationModule.getModule();
    if (module == null) {
        throw CantRunException.noModuleConfigured(runConfigurationModule.getModuleName());
    }
    configureByModule(parameters, module, createModuleJdk(module, jreHome));
}
 
Example #8
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private void configureByModule(SimpleJavaParameters parameters, final Module module, final Sdk jdk) throws CantRunException {
    if (jdk == null) {
        throw CantRunException.noJdkConfigured();
    }
    parameters.setJdk(jdk);
    setDefaultCharset(parameters, module.getProject());
    configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively(), jdk).collectPaths(parameters.getClassPath());
}
 
Example #9
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private SimpleJavaParameters prepareRunnerParameters() throws CantRunException {
    final SimpleJavaParameters parameters = new SimpleJavaParameters();
    parameters.setMainClass(configuration.getRunClass());
    boolean isDebugging = getEnvironment().getExecutor().getId().equals(DefaultDebugExecutor.EXECUTOR_ID);
    parameters.getProgramParametersList().prepend(getSerializedConfig(configuration, isDebugging, port).getAbsolutePath());
    parameters.getClassPath().addFirst(new XQueryRunnerClasspathEntryGenerator().generateRunnerClasspathEntries(configuration));
    return parameters;
}
 
Example #10
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private Sdk createAlternativeJdk(@NotNull String jreHome) throws CantRunException {
    final Sdk configuredJdk = ProjectJdkTable.getInstance().findJdk(jreHome);
    if (configuredJdk != null) {
        return configuredJdk;
    }

    if (!JdkUtil.checkForJre(jreHome) && !JdkUtil.checkForJdk(jreHome)) {
        throw new CantRunException(ExecutionBundle.message("jre.path.is.not.valid.jre.home.error.message", jreHome));
    }

    final String versionString = SdkVersionUtil.detectJdkVersion(jreHome);
    final Sdk jdk = new SimpleJavaSdkType().createJdk(versionString != null ? versionString : "", jreHome);
    if (jdk == null) throw CantRunException.noJdkConfigured();
    return jdk;
}
 
Example #11
Source File: RemoteCommandLineBuilder.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 4 votes vote down vote up
public static GeneralCommandLine createFromJavaParameters(final SimpleJavaParameters javaParameters,
                                                          final Project project,
                                                          final boolean dynamicClasspath) throws CantRunException {
    return createFromJavaParameters(javaParameters, dynamicClasspath && JdkUtil.useDynamicClasspath(project));
}
 
Example #12
Source File: XQueryRunnerClasspathEntryGenerator.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private void validate(XQueryDataSourceConfiguration dataSourceConfiguration) throws CantRunException {
    if (dataSourceConfiguration == null) {
        throw new CantRunException("Configuration is not valid");
    }
}
 
Example #13
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private void configureJreRelatedParameters(SimpleJavaParameters parameters) throws CantRunException {
    final RunConfigurationModule module = configuration.getConfigurationModule();
    final String jreHome = configuration.isAlternativeJrePathEnabled() ? configuration.getAlternativeJrePath() : null;
    configureModule(module, parameters, jreHome);
    configureConfiguration(parameters, configuration);
}
 
Example #14
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private Sdk createModuleJdk(final Module module, @Nullable String jreHome) throws CantRunException {
    return jreHome == null ? getValidJdkToRunModule(module) : createAlternativeJdk(jreHome);
}
 
Example #15
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private GeneralCommandLine createFromJavaParameters(final SimpleJavaParameters javaParameters,
                                                    final Project project) throws CantRunException {
    return createFromJavaParameters(javaParameters, JdkUtil.useDynamicClasspath(project));
}