Search in sources :

Example 11 with CantRunException

use of com.intellij.execution.CantRunException in project intellij-community by JetBrains.

the class JdkUtil method setupJVMCommandLine.

/** @deprecated use {@link SimpleJavaParameters#toCommandLine()} (to be removed in IDEA 2018) */
public static GeneralCommandLine setupJVMCommandLine(final String exePath, final SimpleJavaParameters javaParameters, final boolean forceDynamicClasspath) {
    try {
        javaParameters.setUseDynamicClasspath(forceDynamicClasspath);
        GeneralCommandLine commandLine = new GeneralCommandLine(exePath);
        setupCommandLine(commandLine, javaParameters);
        return commandLine;
    } catch (CantRunException e) {
        throw new RuntimeException(e);
    }
}
Also used : CantRunException(com.intellij.execution.CantRunException) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine)

Example 12 with CantRunException

use of com.intellij.execution.CantRunException in project intellij-plugins by JetBrains.

the class OsgiRunState method getSelectedBundles.

/**
   * Here we got the magic. All libs are turned into bundles sorted and returned.
   */
private List<SelectedBundle> getSelectedBundles() throws ExecutionException {
    final Ref<List<SelectedBundle>> result = Ref.create();
    final Ref<ExecutionException> error = Ref.create();
    ProgressManager.getInstance().run(new Task.Modal(myRunConfiguration.getProject(), "Preparing bundles...", false) {

        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            progressIndicator.setIndeterminate(false);
            AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
            try {
                Set<SelectedBundle> selectedBundles = new HashSet<>();
                // the bundles are module names, by now we try to find jar files in the output directory which we can then install
                ModuleManager moduleManager = ModuleManager.getInstance(myRunConfiguration.getProject());
                BundleCompiler bundleCompiler = new BundleCompiler(progressIndicator);
                int bundleCount = myRunConfiguration.getBundlesToDeploy().size();
                for (int i = 0; i < bundleCount; i++) {
                    progressIndicator.setFraction((double) i / bundleCount);
                    SelectedBundle selectedBundle = myRunConfiguration.getBundlesToDeploy().get(i);
                    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 = bundleCompiler.bundlifyLibraries(module);
                        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<>();
                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();
            }
        }
    });
    if (!result.isNull()) {
        return result.get();
    } else {
        throw error.get();
    }
}
Also used : Task(com.intellij.openapi.progress.Task) SelectedBundle(org.osmorc.run.ui.SelectedBundle) ModuleManager(com.intellij.openapi.module.ModuleManager) CantRunException(com.intellij.execution.CantRunException) OsmorcFacet(org.osmorc.facet.OsmorcFacet) BundleCompiler(org.osmorc.make.BundleCompiler) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AccessToken(com.intellij.openapi.application.AccessToken) OsgiBuildException(org.jetbrains.osgi.jps.build.OsgiBuildException) ExecutionException(com.intellij.execution.ExecutionException) Module(com.intellij.openapi.module.Module)

Example 13 with CantRunException

use of com.intellij.execution.CantRunException in project intellij-plugins by JetBrains.

the class FlexDebugProcess method sendAdlStartingCommand.

private void sendAdlStartingCommand(final FlexBuildConfiguration bc, final BCBasedRunnerParameters params) throws IOException {
    try {
        final Sdk sdk = bc.getSdk();
        LOG.assertTrue(sdk != null);
        final boolean needToRemoveAirRuntimeDir;
        final VirtualFile airRuntimeDirForFlexmojosSdk;
        if (sdk.getSdkType() instanceof FlexmojosSdkType) {
            final Pair<VirtualFile, Boolean> airRuntimeDirInfo;
            airRuntimeDirInfo = FlexSdkUtils.getAirRuntimeDirInfoForFlexmojosSdk(sdk);
            needToRemoveAirRuntimeDir = airRuntimeDirInfo.second;
            airRuntimeDirForFlexmojosSdk = airRuntimeDirInfo.first;
        } else {
            needToRemoveAirRuntimeDir = false;
            airRuntimeDirForFlexmojosSdk = null;
        }
        final String airRuntimePath = airRuntimeDirForFlexmojosSdk == null ? null : airRuntimeDirForFlexmojosSdk.getPath();
        sendCommand(new StartAirAppDebuggingCommand(FlexBaseRunner.createAdlCommandLine(getSession().getProject(), params, bc, airRuntimePath), needToRemoveAirRuntimeDir ? airRuntimeDirForFlexmojosSdk : null));
    } catch (CantRunException e) {
        throw new IOException(e.getMessage());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CantRunException(com.intellij.execution.CantRunException) Sdk(com.intellij.openapi.projectRoots.Sdk) IOException(java.io.IOException) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType)

Example 14 with CantRunException

use of com.intellij.execution.CantRunException in project intellij-community by JetBrains.

the class AntReference method findNotNullAnt.

public static AntInstallation findNotNullAnt(AbstractProperty<AntReference> property, AbstractProperty.AbstractPropertyContainer container, GlobalAntConfiguration antConfiguration) throws CantRunException {
    AntReference antReference = property.get(container);
    if (antReference == PROJECT_DEFAULT)
        antReference = AntConfigurationImpl.DEFAULT_ANT.get(container);
    if (antReference == null)
        throw new CantRunException(AntBundle.message("cant.run.ant.no.ant.configured.error.message"));
    AntInstallation antInstallation = antReference.find(antConfiguration);
    if (antInstallation == null) {
        throw new CantRunException(AntBundle.message("cant.run.ant.ant.reference.is.not.configured.error.message", antReference.getName()));
    }
    return antInstallation;
}
Also used : CantRunException(com.intellij.execution.CantRunException)

Example 15 with CantRunException

use of com.intellij.execution.CantRunException in project intellij-community by JetBrains.

the class ScriptFileUtil method copyToTempFile.

@NotNull
public static File copyToTempFile(@NotNull String path) throws CantRunException {
    VirtualFile virtualFile = findScriptFileByPath(path);
    if (virtualFile == null) {
        throw new CantRunException("File not found: " + path);
    }
    File ioFile;
    try {
        ioFile = FileUtil.createTempFile(virtualFile.getName(), "", true);
    } catch (IOException e) {
        throw new CantRunException("Cannot create temporary file " + virtualFile.getName(), e);
    }
    try {
        copyFile(virtualFile, ioFile);
        return ioFile;
    } catch (IOException e) {
        throw new CantRunException("Cannot write temp file " + virtualFile.getPath() + " to " + ioFile.getAbsolutePath(), e);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CantRunException(com.intellij.execution.CantRunException) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CantRunException (com.intellij.execution.CantRunException)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 Sdk (com.intellij.openapi.projectRoots.Sdk)7 Module (com.intellij.openapi.module.Module)5 File (java.io.File)5 Nullable (org.jetbrains.annotations.Nullable)5 ExecutionException (com.intellij.execution.ExecutionException)4 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)4 JavaParameters (com.intellij.execution.configurations.JavaParameters)4 IOException (java.io.IOException)4 ParametersList (com.intellij.execution.configurations.ParametersList)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Task (com.intellij.openapi.progress.Task)3 SourceScope (com.intellij.execution.testframework.SourceScope)2 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)2 PluginId (com.intellij.openapi.extensions.PluginId)2 Project (com.intellij.openapi.project.Project)2 JavaSdkType (com.intellij.openapi.projectRoots.JavaSdkType)2 SdkTypeId (com.intellij.openapi.projectRoots.SdkTypeId)2 PsiClass (com.intellij.psi.PsiClass)2