Search code examples
eclipseeclipse-plugineclipse-rcpeclipse-cdt

Eclipse get the active build configuration Programaticly


I develop an Eclipse plugin, where I need the information, which build configuration is currently active.

build configs

I have 4 pre-defined Build configurations which you can see in the Screenshot and I need to get the name of the active one and also the name of the active Project.

Something like that.

String activeBuild = getActiveBuild();

I didn't find any solution at the Internet, so does anybody know how to do that?


Solution

  • Assuming you can get your IProject instance as a reference called project, then do the following to obtain the configuration...

    ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(project, true);
    ICConfigurationDescription cfgDescription = desc.getActiveConfiguration();
    IConfiguration configuration = ManagedBuildManager.getConfigurationForDescription(cfgDescription);
    
    // grab what you need from the configuration instance