Search in sources :

Example 16 with ParametersList

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

the class AntCommandLineBuilder method getCommandLine.

public JavaParameters getCommandLine() {
    if (myDone)
        return myCommandLine;
    ParametersList programParameters = myCommandLine.getProgramParametersList();
    for (final String property : myExpandedProperties) {
        if (property != null) {
            programParameters.add(property);
        }
    }
    programParameters.add("-buildfile", myBuildFilePath);
    for (final String target : myTargets) {
        if (target != null) {
            programParameters.add(target);
        }
    }
    myDone = true;
    return myCommandLine;
}
Also used : ParametersList(com.intellij.execution.configurations.ParametersList)

Example 17 with ParametersList

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

the class JUnitDevKitPatcher method patchJavaParameters.

@Override
public void patchJavaParameters(@Nullable Module module, JavaParameters javaParameters) {
    Sdk jdk = javaParameters.getJdk();
    if (jdk == null)
        return;
    ParametersList vm = javaParameters.getVMParametersList();
    if (module != null && PsiUtil.isIdeaProject(module.getProject()) && !vm.hasProperty(SYSTEM_CL_PROPERTY) && !JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_9)) {
        JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
        String qualifiedName = UrlClassLoader.class.getName();
        PsiClass loader = ReadAction.compute(() -> facade.findClass(qualifiedName, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module)));
        if (loader != null) {
            vm.addProperty(SYSTEM_CL_PROPERTY, qualifiedName);
        }
    }
    jdk = IdeaJdk.findIdeaJdk(jdk);
    if (jdk == null)
        return;
    String libPath = jdk.getHomePath() + File.separator + "lib";
    vm.add("-Xbootclasspath/a:" + libPath + File.separator + "boot.jar");
    if (!vm.hasProperty("idea.load.plugins.id") && module != null && PluginModuleType.isOfType(module)) {
        String id = DescriptorUtil.getPluginId(module);
        if (id != null) {
            vm.defineProperty("idea.load.plugins.id", id);
        }
    }
    File sandboxHome = getSandboxPath(jdk);
    if (sandboxHome != null) {
        if (!vm.hasProperty("idea.home.path")) {
            File homeDir = new File(sandboxHome, "test");
            FileUtil.createDirectory(homeDir);
            String buildNumber = IdeaJdk.getBuildNumber(jdk.getHomePath());
            if (buildNumber != null) {
                try {
                    FileUtil.writeToFile(new File(homeDir, "build.txt"), buildNumber);
                } catch (IOException e) {
                    LOG.warn("failed to create build.txt in " + homeDir + ": " + e.getMessage(), e);
                }
            } else {
                LOG.warn("Cannot determine build number for " + jdk.getHomePath());
            }
            vm.defineProperty("idea.home.path", homeDir.getAbsolutePath());
        }
        if (!vm.hasProperty("idea.plugins.path")) {
            vm.defineProperty("idea.plugins.path", new File(sandboxHome, "plugins").getAbsolutePath());
        }
    }
    javaParameters.getClassPath().addFirst(libPath + File.separator + "idea.jar");
    javaParameters.getClassPath().addFirst(libPath + File.separator + "resources.jar");
    javaParameters.getClassPath().addFirst(((JavaSdkType) jdk.getSdkType()).getToolsPath(jdk));
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) ParametersList(com.intellij.execution.configurations.ParametersList) PsiClass(com.intellij.psi.PsiClass) IOException(java.io.IOException) File(java.io.File)

Example 18 with ParametersList

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

the class Flexmojos4GenerateConfigTask method runGeneratorServer.

private void runGeneratorServer(MavenProjectsManager mavenProjectsManager, Project project) throws IOException, ExecutionException, MavenProcessCanceledException {
    final SimpleJavaParameters params = new SimpleJavaParameters();
    params.setJdk(new SimpleJavaSdkType().createJdk("tmp", SystemProperties.getJavaHome()));
    final MavenGeneralSettings mavenGeneralSettings = mavenProjectsManager.getGeneralSettings();
    final ParametersList programParametersList = params.getProgramParametersList();
    programParametersList.add(getSettingsFilePath(mavenGeneralSettings.getEffectiveGlobalSettingsIoFile()));
    programParametersList.add(getSettingsFilePath(mavenGeneralSettings.getEffectiveUserSettingsIoFile()));
    programParametersList.add(mavenGeneralSettings.getEffectiveLocalRepository().getAbsolutePath());
    programParametersList.add(mavenGeneralSettings.isWorkOffline() ? "t" : "f");
    //noinspection ConstantConditions
    programParametersList.add(project.getBaseDir().getPath() + "/.idea/flexmojos");
    configureMavenClassPath(mavenGeneralSettings, params.getClassPath());
    final File userVmP = new File(SystemProperties.getUserHome(), "fcg-vmp");
    if (userVmP.exists()) {
        params.getVMParametersList().addParametersString(FileUtil.loadFile(userVmP));
    }
    params.setMainClass("com.intellij.flex.maven.GeneratorServer");
    final GeneralCommandLine commandLine = params.toCommandLine();
    commandLine.setRedirectErrorStream(true);
    LOG.info("Generate Flex Configs Task:" + commandLine.getCommandLineString());
    indicator.checkCanceled();
    process = commandLine.createProcess();
    ApplicationManager.getApplication().executeOnPooledThread(new OutputReader(project));
    //noinspection IOResourceOpenedButNotSafelyClosed
    out = new DataOutputStream(new BufferedOutputStream(process.getOutputStream()));
    writeExplicitProfiles(mavenProjectsManager.getExplicitProfiles().getEnabledProfiles());
    writeWorkspaceMap(myTree.getProjects());
    out.writeUTF(FlexCommonUtils.getPathToBundledJar("flexmojos-idea-configurator.jar"));
    out.writeUTF(getIdeaConfiguratorClassName());
}
Also used : ParametersList(com.intellij.execution.configurations.ParametersList) SimpleJavaParameters(com.intellij.execution.configurations.SimpleJavaParameters) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) SimpleJavaSdkType(com.intellij.openapi.projectRoots.SimpleJavaSdkType) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 19 with ParametersList

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

the class KnopflerfishRunner method setupParameters.

/**
   * See <a href="http://www.knopflerfish.org/releases/current/docs/running.html">Running Knopflerfish</a>.
   */
@Override
protected void setupParameters(@NotNull JavaParameters parameters) {
    ParametersList vmParameters = parameters.getVMParametersList();
    ParametersList programParameters = parameters.getProgramParametersList();
    // framework-specific options
    vmParameters.addProperty("org.knopflerfish.framework.debug.errors", "true");
    if (GenericRunProperties.isDebugMode(myAdditionalProperties)) {
        // todo: more detailed settings in the dialog (?)
        vmParameters.addProperty("org.knopflerfish.verbosity", "10");
        vmParameters.addProperty("org.knopflerfish.framework.debug.startlevel", "true");
        vmParameters.addProperty("org.knopflerfish.framework.debug.classloader", "true");
    }
    parameters.setMainClass(MAIN_CLASS);
    programParameters.add("-init");
    programParameters.add("-launch");
    // bundles and start levels
    MultiMap<Integer, String> startBundles = new MultiMap<>();
    List<String> installBundles = ContainerUtil.newSmartList();
    for (SelectedBundle bundle : myBundles) {
        String bundlePath = bundle.getBundlePath();
        if (bundlePath == null)
            continue;
        boolean isFragment = CachingBundleInfoProvider.isFragmentBundle(bundlePath);
        if (bundle.isStartAfterInstallation() && !isFragment) {
            int startLevel = getBundleStartLevel(bundle);
            startBundles.putValue(startLevel, bundlePath);
        } else {
            installBundles.add(bundlePath);
        }
    }
    if (!installBundles.isEmpty()) {
        int defaultStartLevel = myRunConfiguration.getDefaultStartLevel();
        programParameters.addAll("-initlevel", String.valueOf(defaultStartLevel));
        for (String bundle : installBundles) {
            programParameters.addAll("-install", bundle);
        }
    }
    for (Integer startLevel : startBundles.keySet()) {
        programParameters.addAll("-initlevel", String.valueOf(startLevel));
        for (String bundle : startBundles.get(startLevel)) {
            programParameters.addAll("-install", bundle);
        }
    }
    int frameworkStartLevel = getFrameworkStartLevel();
    programParameters.addAll("-startlevel", String.valueOf(frameworkStartLevel));
    for (Integer startLevel : startBundles.keySet()) {
        for (String bundle : startBundles.get(startLevel)) {
            programParameters.addAll("-start", bundle);
        }
    }
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) ParametersList(com.intellij.execution.configurations.ParametersList) SelectedBundle(org.osmorc.run.ui.SelectedBundle)

Example 20 with ParametersList

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

the class ConciergeRunner method setupParameters.

/**
   * See <a href="http://concierge.sourceforge.net/properties.html">Concierge Startup Properties</a>.
   */
@Override
protected void setupParameters(@NotNull JavaParameters parameters) {
    ParametersList vmParameters = parameters.getVMParametersList();
    // bundles and start levels
    MultiMap<Integer, String> startBundles = new MultiMap<>();
    List<String> installBundles = ContainerUtil.newSmartList();
    for (SelectedBundle bundle : myBundles) {
        String bundlePath = bundle.getBundlePath();
        if (bundlePath == null)
            continue;
        boolean isFragment = CachingBundleInfoProvider.isFragmentBundle(bundlePath);
        String bundleUrl = toFileUri(bundlePath);
        if (bundle.isStartAfterInstallation() && !isFragment) {
            int startLevel = getBundleStartLevel(bundle);
            startBundles.putValue(startLevel, bundleUrl);
        } else {
            installBundles.add(bundleUrl);
        }
    }
    for (Integer startLevel : startBundles.keySet()) {
        vmParameters.addProperty("osgi.auto.start." + startLevel, StringUtil.join(startBundles.get(startLevel), " "));
    }
    if (!installBundles.isEmpty()) {
        vmParameters.addProperty("osgi.auto.install", StringUtil.join(installBundles, " "));
    }
    int startLevel = getFrameworkStartLevel();
    vmParameters.addProperty("osgi.startlevel.framework", String.valueOf(startLevel));
    int defaultStartLevel = myRunConfiguration.getDefaultStartLevel();
    vmParameters.addProperty("osgi.startlevel.bundle", String.valueOf(defaultStartLevel));
    // framework-specific options
    vmParameters.addProperty("osgi.init", "true");
    if (GenericRunProperties.isDebugMode(myAdditionalProperties)) {
        vmParameters.addProperty("ch.ethz.iks.concierge.debug", "true");
    }
    parameters.setMainClass(MAIN_CLASS);
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) ParametersList(com.intellij.execution.configurations.ParametersList) SelectedBundle(org.osmorc.run.ui.SelectedBundle)

Aggregations

ParametersList (com.intellij.execution.configurations.ParametersList)30 ParamsGroup (com.intellij.execution.configurations.ParamsGroup)9 Test (org.junit.Test)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 File (java.io.File)4 SelectedBundle (org.osmorc.run.ui.SelectedBundle)4 CantRunException (com.intellij.execution.CantRunException)3 Sdk (com.intellij.openapi.projectRoots.Sdk)3 MultiMap (com.intellij.util.containers.MultiMap)3 ExecutionException (com.intellij.execution.ExecutionException)2 JavaParameters (com.intellij.execution.configurations.JavaParameters)2 SimpleJavaParameters (com.intellij.execution.configurations.SimpleJavaParameters)2 JavaSdkType (com.intellij.openapi.projectRoots.JavaSdkType)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 JavaProjectData (com.intellij.externalSystem.JavaProjectData)1 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 PluginId (com.intellij.openapi.extensions.PluginId)1 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 Module (com.intellij.openapi.module.Module)1 SdkTypeId (com.intellij.openapi.projectRoots.SdkTypeId)1