summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Eidsness2013-09-10 21:33:19 (EDT)
committerAndrew Gvozdev2013-10-01 20:59:40 (EDT)
commita0a2059fdd2296fe9fd9c269e129d24fe9b9bf48 (patch)
tree31b4e09d8dcd41badab7b2b9ae25d1c657e0e5e7
parent411734ee3b6aabb21bc6e45a346bf2e1a907df7f (diff)
downloadorg.eclipse.cdt-a0a2059fdd2296fe9fd9c269e129d24fe9b9bf48.zip
org.eclipse.cdt-a0a2059fdd2296fe9fd9c269e129d24fe9b9bf48.tar.gz
org.eclipse.cdt-a0a2059fdd2296fe9fd9c269e129d24fe9b9bf48.tar.bz2
Bug 416471: Support for extra ILanguageSettingsProviders in new projectsrefs/changes/17/16817/7
This change introduces three new ProcessRunners that can be used in the New Project wizard's template.xml files. These will be used by two new Qt project wizards that I will introduce in a second patch. The three new rules are: 1) "AddMakeTarget" which creates new Make Targets (in the Make Targets view) for the new projects. 2) "SetEnvironmentVariable" which sets an environment variable in all of the new project's build configurations. 3) "ExtraLanguageSettingsProvider" which modifies the new project's build configurations to include a new ILanguageSettingsProvider. The first two are straightforward, the third is a bit different. Instead of creating a new Toolchain or Configuration it modifies the Configurations that were created for the new project. In this case the only modification is to add the extra ILanguageSettingsProvider, but it might be useful to extend this to other customizations as well. Change-Id: I30710400e9b0dffcbe6e8965ce7ce2078c1c99ca Signed-off-by: Andrew Eidsness <eclipse@jfront.com> Reviewed-on: https://git.eclipse.org/r/16817 Reviewed-by: Andrew Gvozdev <angvoz.dev@gmail.com> IP-Clean: Andrew Gvozdev <angvoz.dev@gmail.com> Tested-by: Andrew Gvozdev <angvoz.dev@gmail.com>
-rw-r--r--build/org.eclipse.cdt.make.core/plugin.xml12
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/templateengine/AddMakeTarget.java99
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/plugin.xml6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/AddLanguageSettingsProvider.java94
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml11
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineMessages.java5
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties1
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunner.java21
-rw-r--r--core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/SetEnvironmentVariable.java114
9 files changed, 357 insertions, 6 deletions
diff --git a/build/org.eclipse.cdt.make.core/plugin.xml b/build/org.eclipse.cdt.make.core/plugin.xml
index 36067e6..2eded82 100644
--- a/build/org.eclipse.cdt.make.core/plugin.xml
+++ b/build/org.eclipse.cdt.make.core/plugin.xml
@@ -183,4 +183,16 @@
/>
</extension>
+ <extension point="org.eclipse.cdt.core.templateProcessTypes">
+ <processType
+ name="AddMakeTarget"
+ processRunner="org.eclipse.cdt.make.internal.core.templateengine.AddMakeTarget">
+ <simple name="projectName"/>
+ <simple name="targetName"/>
+ <simple name="makeTarget" external="true" nullable="true"/>
+ <simple name="buildCommand" external="true" nullable="true"/>
+ <simple name="buildArguments" external="true" nullable="true"/>
+ </processType>
+ </extension>
+
</plugin>
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/templateengine/AddMakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/templateengine/AddMakeTarget.java
new file mode 100644
index 0000000..b8e59f9
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/templateengine/AddMakeTarget.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2013 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.core.templateengine;
+
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
+import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
+import org.eclipse.cdt.make.core.IMakeTarget;
+import org.eclipse.cdt.make.core.IMakeTargetManager;
+import org.eclipse.cdt.make.core.MakeCorePlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * A step that can be used by the New Project template.xml file to add make targets to
+ * newly created C/C++ projects. E.g.,
+ * <pre>
+ * &lt;process type="org.eclipse.cdt.make.core.AddMakeTarget">
+ * &lt;simple name="projectName" value="$(projectName)"/>
+ * &lt;simple name="targetName" value="build-debug"/>
+ * &lt;simple name="makeTarget" value="debug"/>
+ * &lt;/process>
+ * </pre>
+ * The rule's parameters are used to populate fields in the "Create|Modify Make Target"
+ * dialog box (which is opened from the Make Target view). The two mandatory parameters
+ * are projectName and targetName. There are also three optional parameters:
+ * <p>
+ * <u>makeTarget</u>: The name of the make target to run, defaults to targetName<br>
+ * <u>buildCommand</u>: The build command to execute, e.g., "make"<br>
+ * <u>buildArguments</u>: The arguments that should be passed to the build command, e.g., "-s"<br>
+ */
+public class AddMakeTarget extends ProcessRunner {
+
+ private static final String BUILDER_ID = "org.eclipse.cdt.build.MakeTargetBuilder"; //$NON-NLS-1$
+
+ private static final String PROJECTNAME_VARNAME = "projectName"; //$NON-NLS-1$
+ private static final String TARGETNAME_VARNAME = "targetName"; //$NON-NLS-1$
+ private static final String MAKETARGET_VARNAME = "makeTarget"; //$NON-NLS-1$
+ private static final String BUILDCOMMAND_VARNAME = "buildCommand"; //$NON-NLS-1$
+ private static final String BUILDARGUMENTS_COMMAND_VARNAME = "buildArguments"; //$NON-NLS-1$
+
+ private static final String BUILDCOMMAND_DEFAULT = "make"; //$NON-NLS-1$
+ private static final String BUILDARGUMENTS_DEFAULT = ""; //$NON-NLS-1$
+
+ @Override
+ public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
+ IProject project = null;
+ String targetName = null;
+ String makeTarget = null;
+ String buildCommand = null;
+ String buildArguments = null;
+
+ for (ProcessArgument arg : args) {
+ String argName = arg.getName();
+ if (PROJECTNAME_VARNAME.equals(argName))
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(arg.getSimpleValue());
+ else if (TARGETNAME_VARNAME.equals(argName))
+ targetName = arg.getSimpleValue();
+ else if (MAKETARGET_VARNAME.equals(argName))
+ makeTarget = arg.getSimpleValue();
+ else if (BUILDCOMMAND_VARNAME.equals(argName))
+ buildCommand = arg.getSimpleValue();
+ else if(BUILDARGUMENTS_COMMAND_VARNAME.equals(argName))
+ buildArguments = arg.getSimpleValue();
+ }
+
+ if (project == null)
+ throw missingArgException(processId, PROJECTNAME_VARNAME);
+ if (targetName == null)
+ throw missingArgException(processId, TARGETNAME_VARNAME);
+
+ IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager();
+ try {
+ IMakeTarget target = makeTargetManager.createTarget(project, targetName, BUILDER_ID);
+
+ target.setBuildAttribute(IMakeTarget.BUILD_TARGET, makeTarget == null ? targetName : makeTarget);
+
+ target.setUseDefaultBuildCmd(buildCommand == null);
+ target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, buildCommand == null ? BUILDCOMMAND_DEFAULT : buildCommand);
+ target.setBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, buildArguments == null ? BUILDARGUMENTS_DEFAULT : buildArguments);
+
+ makeTargetManager.addTarget(target);
+ } catch(CoreException e) {
+ throw new ProcessFailureException(e);
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
index 6366525..4498dcd 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml
@@ -584,6 +584,12 @@
processRunner="org.eclipse.cdt.managedbuilder.templateengine.processes.GenerateMakefileWithBuildDescription">
<simple name="projectName"/>
</processType>
+ <processType
+ name="AddLanguageSettingsProvider"
+ processRunner="org.eclipse.cdt.managedbuilder.templateengine.processes.AddLanguageSettingsProvider">
+ <simple name="projectName"/>
+ <simpleArray name="languageSettingsProviderIds"/>
+ </processType>
</extension>
<extension
id="headlessbuild"
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/AddLanguageSettingsProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/AddLanguageSettingsProvider.java
new file mode 100644
index 0000000..23a8fe2
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/templateengine/processes/AddLanguageSettingsProvider.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2013 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.templateengine.processes;
+
+import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
+import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvidersKeeper;
+import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * A configurable stage of the New Project wizard that is able to add implementations of
+ * {@link ILanguageSettingsProvider} to the new project's build configurations.
+ * E.g.,
+ * <pre>
+ &lt;process type="org.eclipse.cdt.managedbuilder.core.AddLanguageSettingsProvider">
+ &lt;simple name="projectName" value="$(projectName)"/>
+ &lt;simple-array name="languageSettingsProviders">
+ &lt;element value="org.eclipse.cdt.qt.core.QtPathsProvider"/>
+ &lt;/simple-array>
+ &lt;/process>
+ * </pre>
+ *
+ * @since 8.3
+ */
+public class AddLanguageSettingsProvider extends ProcessRunner {
+
+ private static final String PROJECTNAME_VARNAME = "projectName"; //$NON-NLS-1$
+ private static final String PROVIDERS_VARNAME = "languageSettingsProviderIds"; //$NON-NLS-1$
+
+ @Override
+ public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
+ IProject project = null;
+ String[] extraProviderIds = null;
+
+ for (ProcessArgument arg : args) {
+ String argName = arg.getName();
+ if (PROJECTNAME_VARNAME.equals(argName))
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(arg.getSimpleValue());
+ else if(PROVIDERS_VARNAME.equals(argName))
+ extraProviderIds = arg.getSimpleArrayValue();
+ }
+
+ if (project == null)
+ throw missingArgException(processId, PROJECTNAME_VARNAME);
+ if (extraProviderIds == null)
+ throw missingArgException(processId, PROVIDERS_VARNAME);
+
+ ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
+ ICProjectDescription des = mngr.getProjectDescription(project, true);
+ ICConfigurationDescription[] configDescs = des.getConfigurations();
+
+ for (ICConfigurationDescription configDesc : configDescs)
+ if (configDesc instanceof ILanguageSettingsProvidersKeeper) {
+ IConfiguration config = ManagedBuildManager.getConfigurationForDescription(configDesc);
+
+ // Create a merged array of the old and new ids
+ String[] ids = config.getDefaultLanguageSettingsProviderIds();
+ String[] newIds = new String[ids.length + extraProviderIds.length];
+ System.arraycopy(ids, 0, newIds, 0, ids.length);
+ System.arraycopy(extraProviderIds, 0, newIds, ids.length, extraProviderIds.length);
+
+ ILanguageSettingsProvidersKeeper keeper = (ILanguageSettingsProvidersKeeper) configDesc;
+ keeper.setLanguageSettingProviders(LanguageSettingsManager.createLanguageSettingsProviders(newIds));
+ }
+
+ try {
+ mngr.setProjectDescription(project, des);
+ } catch(CoreException e) {
+ ManagedBuilderCorePlugin.log(e);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index 235bd07..0d4bbd6 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -782,6 +782,17 @@
name="natureId">
</simple>
</processType>
+ <processType
+ name="SetEnvironmentVariable"
+ processRunner="org.eclipse.cdt.core.templateengine.process.processes.SetEnvironmentVariable">
+ <simple name="projectName"/>
+ <complexArray name="variables">
+ <baseType>
+ <simple name="name"/>
+ <simple name="value"/>
+ </baseType>
+ </complexArray>
+ </processType>
</extension>
<extension
point="org.eclipse.cdt.core.CProjectDescriptionStorage">
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineMessages.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineMessages.java
index bba96d2..4f790d9 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineMessages.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/TemplateEngineMessages.java
@@ -19,6 +19,11 @@ public class TemplateEngineMessages {
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
.getBundle(BUNDLE_NAME);
+ /**
+ * @since 5.6
+ */
+ public static String ProcessRunner_missingArg;
+
private TemplateEngineMessages() {
}
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties
index 08d89dd..43bd4b7 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties
@@ -30,3 +30,4 @@ ProcessRunner.error=-->Error:
ProcessRunner.success=-->Success:
ProcessRunner.info=-->Info:
ProcessHelper.fileNotFound=File not found: ''{0}''
+ProcessRunner_missingArg = ILanguageSettingsProvider failure: argument {0} not found
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunner.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunner.java
index b091e0a..b2742a9 100644
--- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunner.java
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessRunner.java
@@ -15,25 +15,34 @@ import org.eclipse.cdt.core.templateengine.TemplateEngineMessages;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import com.ibm.icu.text.MessageFormat;
/**
* Abstract ProcessRunner class provides the methods to implement for processes.
*/
public abstract class ProcessRunner {
-
+
private ProcessParameter[] params = new ProcessParameter[0];
-
+
void setProcessParameters(ProcessParameter[] params) {
this.params = params == null ? new ProcessParameter[0] : params;
}
-
+
/**
* Returns the Process Parameters.
*/
public ProcessParameter[] getProcessParameters() {
return params;
}
-
+
+ /**
+ * @since 5.6
+ */
+ protected ProcessFailureException missingArgException(String processId, String varname) {
+ String msg = MessageFormat.format(TemplateEngineMessages.ProcessRunner_missingArg, varname);
+ return new ProcessFailureException(getProcessMessage(processId, IStatus.ERROR, msg));
+ }
+
/**
* Checks the whether the arguments are matching the required parameters.
*/
@@ -54,7 +63,7 @@ public abstract class ProcessRunner {
}
return true;
}
-
+
/**
* Return the String containing the mismatching message
* if the arguments are not matching the required parameters.
@@ -95,7 +104,7 @@ public abstract class ProcessRunner {
return processId + TemplateEngineMessages.getString("ProcessRunner.info") + msg; //$NON-NLS-1$
}
}
-
+
/**
* @param template
* @param args
diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/SetEnvironmentVariable.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/SetEnvironmentVariable.java
new file mode 100644
index 0000000..3492ff7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/processes/SetEnvironmentVariable.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2013 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.templateengine.process.processes;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IContributedEnvironment;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * A template process for setting an environment variable in all of the new project's
+ * build configurations. E.g.,
+ * <pre>
+ * &lt;process type="org.eclipse.cdt.core.SetEnvironmentVariable">
+ * &lt;simple name="projectName" value="$(projectName)"/>
+ * &lt;complex-array name="variables">
+ * &lt;element>
+ * &lt;simple name="name" value="QMAKE"/>
+ * &lt;simple name="value" value="$(qmake)"/>
+ * &lt;/element>
+ * &lt;/complex-array>
+ * &lt;/process>
+ * </pre>
+ * This will create an environment variable called "QMAKE" and will set the value to
+ * be the value entered in a field (called qmake) in the New Project wizard.
+ *
+ * @since 5.6
+ */
+public class SetEnvironmentVariable extends ProcessRunner {
+
+ private static final String PROJECTNAME_VARNAME = "projectName"; //$NON-NLS-1$
+ private static final String VARIABLES_VARNAME = "variables"; //$NON-NLS-1$
+ private static final String VARIABLES_NAME_VARNAME = "name"; //$NON-NLS-1$
+ private static final String VARIABLES_VALUE_VARNAME = "value"; //$NON-NLS-1$
+
+ @Override
+ public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
+
+ IProject project = null;
+ Map<String, String> envVars = new LinkedHashMap<String, String>();
+
+ for (ProcessArgument arg : args) {
+ String argName = arg.getName();
+ if (PROJECTNAME_VARNAME.equals(argName))
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(arg.getSimpleValue());
+ else if(VARIABLES_VARNAME.equals(argName)) {
+
+ for(ProcessArgument[] envVarArgs : arg.getComplexArrayValue()) {
+ String name = null;
+ String value = null;
+
+ for(ProcessArgument varArg : envVarArgs) {
+ String varArgName = varArg.getName();
+ if (VARIABLES_NAME_VARNAME.equals(varArgName))
+ name = varArg.getSimpleValue();
+ else if(VARIABLES_VALUE_VARNAME.equals(varArgName))
+ value = varArg.getSimpleValue();
+ }
+
+ if (name == null)
+ throw missingArgException(processId, VARIABLES_NAME_VARNAME);
+ if (value == null)
+ throw missingArgException(processId, VARIABLES_VALUE_VARNAME);
+
+ envVars.put(name, value);
+ }
+ }
+ }
+
+ if (project == null)
+ throw missingArgException(processId, PROJECTNAME_VARNAME);
+
+ ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
+ ICProjectDescription des = mngr.getProjectDescription(project, true);
+ ICConfigurationDescription[] configDescs = des.getConfigurations();
+ IContributedEnvironment ice = CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment();
+
+ for(Map.Entry<String, String> envVar : envVars.entrySet()) {
+ String name = envVar.getKey();
+ String value = envVar.getValue();
+
+ for (ICConfigurationDescription configDesc : configDescs)
+ ice.addVariable(name, value, IEnvironmentVariable.ENVVAR_REPLACE, null, configDesc);
+ }
+
+ try {
+ mngr.setProjectDescription(project, des);
+ } catch(CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+}