Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Project Environment Not Being Updated

Hi all,

I'm trying to modify the environment variables of a custom projectType
that I created. I set the projectEnvironmentSupplier variable to a
class that extends the IProjectEnvironmentVariableSupplier interface
and I think I implemented it correctly. The getVariables() function
does get called when I create a projectType or start a new eclipse
session (once for each project), but I cannot see any of the custom
variables under Project Icon -> Properties -> C/C++ Build ->

Also I have another related question. If I launch a new system program
using ProcessFactory.getFactory().exec(), does it use the environment
of the project?

Karol Krizka

//Find the environment, used later in CMTEnvironment
	public EnvVar[] getEnvironment()
		String[] env=sh.environment();
		EnvVar[] ret=new EnvVar[env.length];
		//Convert from Java format to CDT format
		for(int i=0;i<env.length;i++)
			String[] set=env[i].split("=",2);
			ret[i]=new EnvVar(set[0],set[1]);			
		return ret;

public class CMTEnvironment implements IProjectEnvironmentVariableSupplier {
	private CMTHome ch;
	public CMTEnvironment()

	public IBuildEnvironmentVariable getVariable(String variableName,
			IManagedProject project, IEnvironmentVariableProvider provider) {
		EnvVar[] vars=ch.getEnvironment();
		for(int i=0;i<vars.length;i++)
			if(vars[i].getName()==variableName) return vars[i];
		return null;

	public IBuildEnvironmentVariable[] getVariables(IManagedProject project,
			IEnvironmentVariableProvider provider)
		return ch.getEnvironment();


public class EnvVar implements IBuildEnvironmentVariable
    public static final int ENVVAR_REPLACE = 1;
    public static final int ENVVAR_REMOVE = 2;
    public static final int ENVVAR_PREPEND = 3;
    public static final int ENVVAR_APPEND = 4;

	private String name;
	private String value;
	public EnvVar(String _n,String _v)
	public String getName()
		return name;
	public String getDelimiter()
		return ";";
	public int getOperation()
	public String getValue()
		return value;
	public String toString()
		return name+" = "+value;

Back to the top