From be6e4036d81dc7cfe26218b8c7518ee19ec6be96 Mon Sep 17 00:00:00 2001 From: Mikhail Sennikovsky Date: Mon, 15 May 2006 15:06:42 +0000 Subject: [PATCH] Changed the buildInfoVersion to 3.1 --- .../core/ManagedBuildManager.java | 2 +- .../UpdateManagedProject21.java | 4 +- .../UpdateManagedProject30.java | 79 +++++++++++++++++++ .../UpdateManagedProjectManager.java | 6 +- 4 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject30.java diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index 887ffff952b..34eb4c1c082 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -135,7 +135,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI private static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$ // This is the version of the manifest and project files - private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(3, 0, 0); + private static final PluginVersionIdentifier buildInfoVersion = new PluginVersionIdentifier(3, 1, 0); private static Map depCalculatorsMap; private static boolean projectTypesLoaded = false; private static boolean projectTypesLoading = false; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java index 0aecbdef9fb..2a07c479a83 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject21.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 Intel Corporation and others. + * Copyright (c) 2005, 2006 Intel Corporation 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 @@ -68,7 +68,7 @@ class UpdateManagedProject21 { // No physical conversion is need since the 3.0 model is a superset of the 2.1 model // We need to upgrade the version - ((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString()); + ((ManagedBuildInfo)info).setVersion("3.0.0"); //$NON-NLS-1$ info.setValid(true); // Save the updated file. diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject30.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject30.java new file mode 100644 index 00000000000..06f510c3b23 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProject30.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2006 Intel Corporation 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: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.projectconverter; + +import java.io.File; + +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.WorkspaceJob; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.ISchedulingRule; +import org.eclipse.core.runtime.jobs.MultiRule; + +public class UpdateManagedProject30 { + + /** + * @param monitor the monitor to allow users to cancel the long-running operation + * @param project the IProject that needs to be upgraded + * @throws CoreException + */ + static void doProjectUpdate(IProgressMonitor monitor, final IProject project) throws CoreException { + String[] projectName = new String[]{project.getName()}; + IFile file = project.getFile(ManagedBuildManager.SETTINGS_FILE_NAME); + File settingsFile = file.getLocation().toFile(); + if (!settingsFile.exists()) { + monitor.done(); + return; + } + + // Backup the file + monitor.beginTask(ConverterMessages.getFormattedString("UpdateManagedProject20.0", projectName), 1); //$NON-NLS-1$ + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + UpdateManagedProjectManager.backupFile(file, "_30backup", monitor, project); //$NON-NLS-1$ + + // No physical conversion is need since the 3.1 model is a superset of the 3.0 model + // We need to upgrade the version + ((ManagedBuildInfo)info).setVersion(ManagedBuildManager.getBuildInfoVersion().toString()); + info.setValid(true); + + // Save the updated file. + IWorkspace workspace = project.getWorkspace(); +// boolean treeLock = workspace.isTreeLocked(); + ISchedulingRule rule1 = workspace.getRuleFactory().createRule(project); + ISchedulingRule rule2 = workspace.getRuleFactory().refreshRule(project); + ISchedulingRule rule = MultiRule.combine(rule1, rule2); + //since the java synchronized mechanism is now used for the build info loadding, + //initiate the job in all cases +// if (treeLock) { + WorkspaceJob job = new WorkspaceJob(ConverterMessages.getResourceString("UpdateManagedProject.notice")) { //$NON-NLS-1$ + public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { + ManagedBuildManager.saveBuildInfo(project, true); + return Status.OK_STATUS; + } + }; + job.setRule(rule); + job.schedule(); +// } else { +// checkForCPPWithC(monitor, project); +// ManagedBuildManager.saveBuildInfo(project, true); +// } + monitor.done(); + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java index 242f9b81058..15c829ed106 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/projectconverter/UpdateManagedProjectManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 Intel Corporation and others. + * Copyright (c) 2004, 2006 Intel Corporation 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 @@ -314,6 +314,10 @@ public class UpdateManagedProjectManager { UpdateManagedProject21.doProjectUpdate(monitor, fProject); version = getManagedBuildInfoVersion(info.getVersion()); } + if(version.isEquivalentTo(new PluginVersionIdentifier(3,0,0))){ + UpdateManagedProject30.doProjectUpdate(monitor, fProject); + version = getManagedBuildInfoVersion(info.getVersion()); + } if(!isCompatibleProject(info)){ throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.getUniqueIdentifier(), -1,