Search in sources :

Example 1 with IBuildProperty

use of org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty in project m2e-nar by maven-nar.

the class CProjectConfigurator method getCdtMavenConfig.

private ICConfigurationDescription getCdtMavenConfig(IProject project, ICProjectDescription des, IToolChain tc, String artefactType, String name, boolean setActive, IProgressMonitor monitor) throws CoreException {
    IManagedProject mProj = ManagedBuildManager.getBuildInfo(project).getManagedProject();
    ICConfigurationDescription mavenCfg = des.getConfigurationByName(name);
    if (mavenCfg == null) {
        List<IConfiguration> cfgs = getCfgs(tc, artefactType);
        if (cfgs.isEmpty()) {
            throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Cannot find any configurations"));
        }
        monitor.worked(10);
        monitor.worked(10);
        // cfgs = CfgHolder.unique(cfgs);
        // cfgs = CfgHolder.reorder(cfgs);
        IConfiguration cfgRelease = null;
        IConfiguration cfgFirst = null;
        int work = 50 / cfgs.size();
        for (IConfiguration cfg : cfgs) {
            IBuildProperty b = cfg.getBuildProperties().getProperty(ManagedBuildManager.BUILD_TYPE_PROPERTY_ID);
            if (cfgRelease == null && b != null && b.getValue() != null && ManagedBuildManager.BUILD_TYPE_PROPERTY_RELEASE.equals(b.getValue().getId())) {
                cfgRelease = cfg;
            }
            if (cfgFirst == null) {
                cfgFirst = cfg;
            }
            monitor.worked(work);
        }
        if (cfgFirst != null) {
            if (cfgRelease != null) {
                cfgFirst = cfgRelease;
            }
            MavenNarPlugin.getDefault().log("Creating configuration " + name);
            IConfiguration newCfg = createConfiguration(cfgFirst, mProj, des);
            newCfg.setName(name);
            newCfg.setDescription("m2e generated configuration");
            mavenCfg = ManagedBuildManager.getDescriptionForConfiguration(newCfg);
        }
    }
    if (mavenCfg != null) {
        if (setActive) {
            des.setActiveConfiguration(mavenCfg);
        }
        return mavenCfg;
    } else {
        throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Cannot find any configurations"));
    }
// mngr.setProjectDescription(project, des);
}
Also used : IManagedProject(org.eclipse.cdt.managedbuilder.core.IManagedProject) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) IBuildProperty(org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty) ICConfigurationDescription(org.eclipse.cdt.core.settings.model.ICConfigurationDescription) IConfiguration(org.eclipse.cdt.managedbuilder.core.IConfiguration)

Aggregations

ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)1 IBuildProperty (org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty)1 IConfiguration (org.eclipse.cdt.managedbuilder.core.IConfiguration)1 IManagedProject (org.eclipse.cdt.managedbuilder.core.IManagedProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1