diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup')
10 files changed, 825 insertions, 962 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Activator.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Activator.java index 224059588f..3a6d3558d6 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Activator.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Activator.java @@ -10,18 +10,9 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.setup.GitClone; import org.eclipse.emf.cdo.releng.setup.Setup; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; - -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.resource.ImageDescriptor; @@ -35,7 +26,7 @@ import java.io.File; /** * @author Eike Stepper */ -public class Activator extends AbstractUIPlugin implements SetupContext +public class Activator extends AbstractUIPlugin // implements SetupContext { public static final String PLUGIN_ID = "org.eclipse.emf.cdo.releng.setup.ide"; @@ -76,15 +67,15 @@ public class Activator extends AbstractUIPlugin implements SetupContext return new File(branchDir, "eclipse"); } - public File getGitDir() - { - return new File(branchDir, "git"); - } - - public File getWorkDir(GitClone clone) - { - return new File(getGitDir(), clone.getName()); - } + // public File getGitDir() + // { + // return new File(branchDir, "git"); + // } + // + // public File getWorkDir(GitClone clone) + // { + // return new File(getGitDir(), clone.getName()); + // } public File getWorkspaceDir() { @@ -108,27 +99,27 @@ public class Activator extends AbstractUIPlugin implements SetupContext bundleContext = context; plugin = this; - try - { - if ("true".equals(System.getProperty("org.eclipse.emf.cdo.releng.setup.ide", "false"))) - { - ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); - - IPath branchDirPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().removeLastSegments(1); - branchDir = new File(branchDirPath.toOSString()); - - URI uri = URI.createFileURI(branchDirPath.append("setup.xmi").toOSString()); - Resource resource = resourceSet.getResource(uri, true); - - setup = (Setup)resource.getContents().get(0); - SetupIDE.run(); - } - } - catch (Exception ex) - { - log(ex); - } + // try + // { + // if ("true".equalsIgnoreCase(System.getProperty("org.eclipse.emf.cdo.releng.setup.ide", "false"))) + // { + // ResourceSet resourceSet = new ResourceSetImpl(); + // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); + // + // IPath branchDirPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().removeLastSegments(1); + // branchDir = new File(branchDirPath.toOSString()); + // + // URI uri = URI.createFileURI(branchDirPath.append("setup.xmi").toOSString()); + // Resource resource = resourceSet.getResource(uri, true); + // + // setup = (Setup)resource.getContents().get(0); + // SetupIDE.run(); + // } + // } + // catch (Exception ex) + // { + // log(ex); + // } } @Override diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Buckminster.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Buckminster.java index c1ec16af4c..0100176102 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Buckminster.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Buckminster.java @@ -10,345 +10,313 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.setup.ApiBaseline; -import org.eclipse.emf.cdo.releng.setup.Branch; -import org.eclipse.emf.cdo.releng.setup.GitClone; -import org.eclipse.emf.cdo.releng.setup.Project; -import org.eclipse.emf.cdo.releng.setup.Setup; -import org.eclipse.emf.cdo.releng.setup.helper.Downloads; -import org.eclipse.emf.cdo.releng.setup.helper.Files; -import org.eclipse.emf.cdo.releng.setup.helper.OS; -import org.eclipse.emf.cdo.releng.setup.helper.Progress; -import org.eclipse.emf.cdo.releng.setup.helper.ProgressLogProvider; - -import org.eclipse.net4j.util.io.FileLock; -import org.eclipse.net4j.util.io.ZIPUtil; -import org.eclipse.net4j.util.io.ZIPUtil.FileSystemUnzipHandler; - -import org.eclipse.buckminster.cmdline.Headless; -import org.eclipse.buckminster.core.commands.Import; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.jobs.ProgressProvider; -import org.eclipse.equinox.p2.publisher.AbstractPublisherApplication; -import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAndBundlesPublisherApplication; -import org.eclipse.ui.internal.progress.ProgressManager; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; /** * @author Eike Stepper */ +@Deprecated public final class Buckminster { - private static final SetupContext CONTEXT = Activator.getDefault(); - - // TODO Don't use Headless because if cancels important jobs! Use e.g. ImportAction code instead... - public static void run(String... args) throws Exception - { - Activator.log("Buckminster command: " + Arrays.asList(args)); - - try - { - Headless buckminster = new Headless(); - buckminster.run(args); - } - finally - { - Job.getJobManager().setProgressProvider(ProgressManager.getInstance()); - } - } - - public static void importBaseline() throws Exception - { - Branch branch = CONTEXT.getSetup().getBranch(); - ApiBaseline apiBaseline = branch.getApiBaseline(); - if (apiBaseline == null) - { - return; - } - - boolean autoBuilding = disableAutoBuilding(); - - try - { - String version = apiBaseline.getVersion(); - Progress.log().addLine("Setting baseline " + version); - - final File baselineDir = CONTEXT.getBaselineDir(); - File target = new File(baselineDir, version); - if (!target.exists()) - { - String url = apiBaseline.getZipLocation(); - File file = Downloads.downloadURL(url); - baselineDir.mkdirs(); - - final File[] rootDir = { null }; - ZIPUtil.unzip(file, new FileSystemUnzipHandler(baselineDir, ZIPUtil.DEFALULT_BUFFER_SIZE) - { - @Override - public void unzipFile(String name, InputStream zipStream) - { - if (rootDir[0] == null) - { - rootDir[0] = new File(baselineDir, new Path(name).segment(0)); - } - - Progress.log().addLine("Unzipping " + name); - super.unzipFile(name, zipStream); - } - }); - - rootDir[0].renameTo(target); - } - - String name = apiBaseline.getProject().getName() + " Baseline"; - importTarget(target, name, false); - - Progress.log().addLine("Setting baseline: " + name); - run("addbaseline", "-A", name); - } - finally - { - restoreAutoBuilding(autoBuilding); - } - } - - private static String getTargetName() - { - Setup setup = CONTEXT.getSetup(); - Branch branch = setup.getBranch(); - Project project = branch.getProject(); - return project.getName() + " Target"; - } - - private static String createTargetDefinition(File folder, String name) throws IOException - { - File xml = getTargetXML(folder); - String xmlPath = xml.getAbsolutePath(); - Progress.log().addLine("Creating target definition: " + xmlPath); - - List<String> lines = new ArrayList<String>(); - lines.add("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"); - lines.add("<?pde version=\"3.8\"?>"); - lines.add("<target name=\"" + name + "\" sequenceNumber=\"0\">"); - lines.add(" <locations>"); - lines.add(" <location path=\"" + folder.getCanonicalPath().replace('\\', '/') + "\" type=\"Directory\"/>"); - lines.add(" </locations>"); - lines.add("</target>"); - - folder.mkdirs(); - OS.INSTANCE.writeText(xml, lines); - return xmlPath; - } - - private static void importTarget(File folder, String name, boolean activate) throws Exception - { - String xmlPath = createTargetDefinition(folder, name); - Progress.log().addLine("Loading target definition: " + xmlPath); - - if (activate) - { - run("importtarget", "--active", xmlPath); - } - else - { - run("importtarget", xmlPath); - } - } - - public static void importTarget() throws Exception - { - File targetPlatformDir = CONTEXT.getTargetPlatformDir(); - String name = getTargetName(); - - boolean autoBuilding = disableAutoBuilding(); - - try - { - importTarget(targetPlatformDir, name, true); - } - finally - { - restoreAutoBuilding(autoBuilding); - } - } - - public static void importMSpec() throws Exception - { - initVars(); - - File tpOld = null; - File tp = CONTEXT.getTargetPlatformDir(); - if (tp.exists()) - { - tpOld = new File(tp.getParentFile(), tp.getName() + "." + System.currentTimeMillis()); - Files.rename(tp, tpOld); - } - - FileLock tpPoolLock = null; - boolean autoBuilding = disableAutoBuilding(); - - try - { - File tpPool = updateTargetPlatformPool(); - tpPoolLock = FileLock.forWrite(tpPool); - - File gitDir = CONTEXT.getGitDir(); - Setup setup = CONTEXT.getSetup(); - - Progress.log().addLine("Creating new target platform folder"); - createTargetDefinition(tp, getTargetName()); - - String bomPath = new File(CONTEXT.getBranchDir(), "bom.xml").getAbsolutePath(); - String mspecPath = new File(gitDir, setup.getBranch().getMspecFilePath()).getAbsolutePath(); - Progress.log().addLine("Importing MSpec " + mspecPath); - - run("--displaystacktrace", "import2", "-B", bomPath, mspecPath); - - if (tpPoolLock != null) - { - updateBundlePool(tp.getAbsolutePath(), tpPool.getAbsolutePath()); - } - - if (Progress.log().isCancelled()) - { - throw new InterruptedException(); - } - } - catch (Exception ex) - { - File tpBroken = new File(tp.getParentFile(), tp.getName() + "." + System.currentTimeMillis()); - Files.rename(tp, tpBroken); - if (tpOld != null) - { - Files.rename(tpOld, tp); - } - - Files.deleteAsync(tpBroken); - throw ex; - } - finally - { - try - { - if (tpPoolLock != null) - { - tpPoolLock.release(); - } - } - finally - { - restoreAutoBuilding(autoBuilding); - } - } - - if (tpOld != null) - { - Files.deleteAsync(tpOld); - } - } - - private static File updateTargetPlatformPool() throws Exception - { - File installFolder = new File(CONTEXT.getSetup().getPreferences().getInstallFolder()); - - File idePool = new File(installFolder, ".p2pool-ide"); - idePool.mkdirs(); - - File tpPool = new File(installFolder, ".p2pool-tp"); - tpPool.mkdirs(); - - FileLock idePoolLock = FileLock.forWrite(idePool); - - try - { - updateBundlePool(idePool.getAbsolutePath(), tpPool.getAbsolutePath()); - } - finally - { - idePoolLock.release(); - } - - return tpPool; - } - - private static File getTargetXML(File folder) - { - return new File(folder, "target.xml"); - } - - private static void initVars() throws Exception - { - Setup setup = CONTEXT.getSetup(); - Branch branch = setup.getBranch(); - - for (GitClone gitClone : branch.getGitClones()) - { - File workDir = CONTEXT.getWorkDir(gitClone); - String cloneName = workDir.getName(); - String variableName = branch.getCloneVariableName(); - if (variableName == null) - { - variableName = "git.clone." + cloneName; - } - - String description = "Location of " + cloneName + " git clone"; - Variables.set(variableName, description, workDir.getAbsolutePath().replace('\\', '/')); - } - } - - private static void updateBundlePool(String source, String bundlePool) throws Exception - { - Progress.log().addLine("Updating bundle pool: " + bundlePool); - - String bundlePoolURL = "file:/" + bundlePool.replace('\\', '/'); - String[] args = { "-source", source, "-metadataRepository", bundlePoolURL, "-artifactRepository", bundlePoolURL, - "-append", "-publishArtifacts" }; - - AbstractPublisherApplication publisher = new FeaturesAndBundlesPublisherApplication(); - publisher.run(args); - } - - public static boolean disableAutoBuilding() throws CoreException - { - boolean autoBuilding = ResourcesPlugin.getWorkspace().isAutoBuilding(); - if (autoBuilding) - { - restoreAutoBuilding(false); - } - - return autoBuilding; - } - - public static void restoreAutoBuilding(boolean autoBuilding) throws CoreException - { - if (autoBuilding != ResourcesPlugin.getWorkspace().isAutoBuilding()) - { - IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); - description.setAutoBuilding(autoBuilding); - - ResourcesPlugin.getWorkspace().setDescription(description); - } - } - - /** - * @author Eike Stepper - */ - public static class ImportCommand extends Import - { - @Override - public ProgressProvider getProgressProvider() - { - return new ProgressLogProvider(Progress.log(), ProgressManager.getInstance()); - } - } + // private static final SetupContext CONTEXT = Activator.getDefault(); + // + // // TODO Don't use Headless because if cancels important jobs! Use e.g. ImportAction code instead... + // public static void run(String... args) throws Exception + // { + // Activator.log("Buckminster command: " + Arrays.asList(args)); + // + // try + // { + // Headless buckminster = new Headless(); + // buckminster.run(args); + // } + // finally + // { + // Job.getJobManager().setProgressProvider(ProgressManager.getInstance()); + // } + // } + // + // public static void importBaseline() throws Exception + // { + // Branch branch = CONTEXT.getSetup().getBranch(); + // ApiBaseline apiBaseline = branch.getApiBaseline(); + // if (apiBaseline == null) + // { + // return; + // } + // + // boolean autoBuilding = disableAutoBuilding(); + // + // try + // { + // String version = apiBaseline.getVersion(); + // Progress.log().addLine("Setting baseline " + version); + // + // final File baselineDir = CONTEXT.getBaselineDir(); + // File target = new File(baselineDir, version); + // if (!target.exists()) + // { + // String url = apiBaseline.getZipLocation(); + // File file = DownloadUtil.downloadURL(url); + // baselineDir.mkdirs(); + // + // final File[] rootDir = { null }; + // ZIPUtil.unzip(file, new FileSystemUnzipHandler(baselineDir, ZIPUtil.DEFAULT_BUFFER_SIZE) + // { + // @Override + // public void unzipFile(String name, InputStream zipStream) + // { + // if (rootDir[0] == null) + // { + // rootDir[0] = new File(baselineDir, new Path(name).segment(0)); + // } + // + // Progress.log().addLine("Unzipping " + name); + // super.unzipFile(name, zipStream); + // } + // }); + // + // rootDir[0].renameTo(target); + // } + // + // String name = apiBaseline.getProject().getName() + " Baseline"; + // importTarget(target, name, false); + // + // Progress.log().addLine("Setting baseline: " + name); + // run("addbaseline", "-A", name); + // } + // finally + // { + // restoreAutoBuilding(autoBuilding); + // } + // } + // + // private static String getTargetName() + // { + // Setup setup = CONTEXT.getSetup(); + // Branch branch = setup.getBranch(); + // Project project = branch.getProject(); + // return project.getName() + " Target"; + // } + // + // private static String createTargetDefinition(File folder, String name) throws IOException + // { + // File xml = getTargetXML(folder); + // String xmlPath = xml.getAbsolutePath(); + // Progress.log().addLine("Creating target definition: " + xmlPath); + // + // List<String> lines = new ArrayList<String>(); + // lines.add("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"); + // lines.add("<?pde version=\"3.8\"?>"); + // lines.add("<target name=\"" + name + "\" sequenceNumber=\"0\">"); + // lines.add(" <locations>"); + // lines.add(" <location path=\"" + folder.getCanonicalPath().replace('\\', '/') + "\" type=\"Directory\"/>"); + // lines.add(" </locations>"); + // lines.add("</target>"); + // + // folder.mkdirs(); + // OS.INSTANCE.writeText(xml, lines); + // return xmlPath; + // } + // + // private static void importTarget(File folder, String name, boolean activate) throws Exception + // { + // String xmlPath = createTargetDefinition(folder, name); + // Progress.log().addLine("Loading target definition: " + xmlPath); + // + // if (activate) + // { + // run("importtarget", "--active", xmlPath); + // } + // else + // { + // run("importtarget", xmlPath); + // } + // } + // + // public static void importTarget() throws Exception + // { + // File targetPlatformDir = CONTEXT.getTargetPlatformDir(); + // String name = getTargetName(); + // + // boolean autoBuilding = disableAutoBuilding(); + // + // try + // { + // importTarget(targetPlatformDir, name, true); + // } + // finally + // { + // restoreAutoBuilding(autoBuilding); + // } + // } + // + // public static void importMSpec() throws Exception + // { + // initVars(); + // + // File tpOld = null; + // File tp = CONTEXT.getTargetPlatformDir(); + // if (tp.exists()) + // { + // tpOld = new File(tp.getParentFile(), tp.getName() + "." + System.currentTimeMillis()); + // Files.rename(tp, tpOld); + // } + // + // FileLock tpPoolLock = null; + // boolean autoBuilding = disableAutoBuilding(); + // + // try + // { + // File tpPool = updateTargetPlatformPool(); + // tpPoolLock = FileLock.forWrite(tpPool); + // + // File gitDir = CONTEXT.getGitDir(); + // Setup setup = CONTEXT.getSetup(); + // + // Progress.log().addLine("Creating new target platform folder"); + // createTargetDefinition(tp, getTargetName()); + // + // String bomPath = new File(CONTEXT.getBranchDir(), "bom.xml").getAbsolutePath(); + // String mspecPath = new File(gitDir, setup.getBranch().getMspecFilePath()).getAbsolutePath(); + // Progress.log().addLine("Importing MSpec " + mspecPath); + // + // run("--displaystacktrace", "import2", "-B", bomPath, mspecPath); + // + // if (tpPoolLock != null) + // { + // updateBundlePool(tp.getAbsolutePath(), tpPool.getAbsolutePath()); + // } + // + // if (Progress.log().isCancelled()) + // { + // throw new InterruptedException(); + // } + // } + // catch (Exception ex) + // { + // File tpBroken = new File(tp.getParentFile(), tp.getName() + "." + System.currentTimeMillis()); + // Files.rename(tp, tpBroken); + // if (tpOld != null) + // { + // Files.rename(tpOld, tp); + // } + // + // Files.deleteAsync(tpBroken); + // throw ex; + // } + // finally + // { + // try + // { + // if (tpPoolLock != null) + // { + // tpPoolLock.release(); + // } + // } + // finally + // { + // restoreAutoBuilding(autoBuilding); + // } + // } + // + // if (tpOld != null) + // { + // Files.deleteAsync(tpOld); + // } + // } + // + // private static File updateTargetPlatformPool() throws Exception + // { + // File installFolder = new File(CONTEXT.getSetup().getPreferences().getInstallFolder()); + // + // File idePool = new File(installFolder, ".p2pool-ide"); + // idePool.mkdirs(); + // + // File tpPool = new File(installFolder, ".p2pool-tp"); + // tpPool.mkdirs(); + // + // FileLock idePoolLock = FileLock.forWrite(idePool); + // + // try + // { + // updateBundlePool(idePool.getAbsolutePath(), tpPool.getAbsolutePath()); + // } + // finally + // { + // idePoolLock.release(); + // } + // + // return tpPool; + // } + // + // private static File getTargetXML(File folder) + // { + // return new File(folder, "target.xml"); + // } + // + // private static void initVars() throws Exception + // { + // Setup setup = CONTEXT.getSetup(); + // Branch branch = setup.getBranch(); + // + // for (GitClone gitClone : branch.getGitClones()) + // { + // File workDir = CONTEXT.getWorkDir(gitClone); + // String cloneName = workDir.getName(); + // String variableName = branch.getCloneVariableName(); + // if (variableName == null) + // { + // variableName = "git.clone." + cloneName; + // } + // + // String description = "Location of " + cloneName + " git clone"; + // Variables.set(variableName, description, workDir.getAbsolutePath().replace('\\', '/')); + // } + // } + // + // private static void updateBundlePool(String source, String bundlePool) throws Exception + // { + // Progress.log().addLine("Updating bundle pool: " + bundlePool); + // + // String bundlePoolURL = "file:/" + bundlePool.replace('\\', '/'); + // String[] args = { "-source", source, "-metadataRepository", bundlePoolURL, "-artifactRepository", bundlePoolURL, + // "-append", "-publishArtifacts" }; + // + // AbstractPublisherApplication publisher = new FeaturesAndBundlesPublisherApplication(); + // publisher.run(args); + // } + // + // public static boolean disableAutoBuilding() throws CoreException + // { + // boolean autoBuilding = ResourcesPlugin.getWorkspace().isAutoBuilding(); + // if (autoBuilding) + // { + // restoreAutoBuilding(false); + // } + // + // return autoBuilding; + // } + // + // public static void restoreAutoBuilding(boolean autoBuilding) throws CoreException + // { + // if (autoBuilding != ResourcesPlugin.getWorkspace().isAutoBuilding()) + // { + // IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); + // description.setAutoBuilding(autoBuilding); + // + // ResourcesPlugin.getWorkspace().setDescription(description); + // } + // } + // + // /** + // * @author Eike Stepper + // */ + // public static class ImportCommand extends Import + // { + // @Override + // public ProgressProvider getProgressProvider() + // { + // return new ProgressLogProvider(Progress.log(), ProgressManager.getInstance()); + // } + // } } diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/GitClones.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/GitClones.java index 8c0953ba84..1a68d4f7d3 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/GitClones.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/GitClones.java @@ -10,226 +10,194 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.setup.Branch; -import org.eclipse.emf.cdo.releng.setup.GitClone; -import org.eclipse.emf.cdo.releng.setup.Setup; -import org.eclipse.emf.cdo.releng.setup.helper.Files; -import org.eclipse.emf.cdo.releng.setup.helper.OS; -import org.eclipse.emf.cdo.releng.setup.helper.Progress; - -import org.eclipse.emf.common.util.URI; - -import org.eclipse.jgit.api.CheckoutCommand; -import org.eclipse.jgit.api.CloneCommand; -import org.eclipse.jgit.api.CreateBranchCommand; -import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.ResetCommand; -import org.eclipse.jgit.api.ResetCommand.ResetType; -import org.eclipse.jgit.api.StatusCommand; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.errors.NoWorkTreeException; -import org.eclipse.jgit.lib.ConfigConstants; -import org.eclipse.jgit.lib.CoreConfig.AutoCRLF; -import org.eclipse.jgit.lib.ProgressMonitor; -import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.lib.StoredConfig; -import org.eclipse.jgit.transport.RefSpec; -import org.eclipse.jgit.transport.RemoteConfig; - -import java.io.File; -import java.util.Collections; -import java.util.List; -import java.util.Map; - /** * @author Eike Stepper */ +@Deprecated public final class GitClones { - private static final SetupContext CONTEXT = Activator.getDefault(); - - public static void init() throws Exception - { - Setup setup = CONTEXT.getSetup(); - Branch branch = setup.getBranch(); - String userName = setup.getPreferences().getUserName(); - - for (GitClone gitClone : branch.getGitClones()) - { - File workDir = CONTEXT.getWorkDir(gitClone); - - Repository repository = null; - Git git = null; - - try - { - boolean needsClone = true; - if (workDir.isDirectory()) - { - Progress.log().addLine("Opening Git clone " + workDir); - git = Git.open(workDir); - if (hasWorkingDirectory(git)) - { - needsClone = false; - } - else - { - Files.rename(workDir); - } - } - - String checkoutBranch = gitClone.getCheckoutBranch(); - if (needsClone) - { - URI baseURI = URI.createURI(gitClone.getRemoteURI()); - String remote = URI.createHierarchicalURI(baseURI.scheme(), userName + "@" + baseURI.authority(), - baseURI.device(), baseURI.segments(), baseURI.query(), baseURI.fragment()).toString(); - Progress.log().addLine("Cloning Git repo " + remote + " to " + workDir); - - CloneCommand command = Git.cloneRepository(); - command.setNoCheckout(true); - command.setURI(remote); - command.setRemote("origin"); - command.setBranchesToClone(Collections.singleton(checkoutBranch)); - command.setDirectory(workDir); - command.setTimeout(10); - command.setProgressMonitor(new ProgressLogWrapper()); - - git = command.call(); - } - - repository = git.getRepository(); - StoredConfig config = repository.getConfig(); - - boolean changed = false; - if (OS.INSTANCE.isLineEndingConversionNeeded()) - { - changed = true; - config.setEnum(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, AutoCRLF.TRUE); - } - - String gerritQueue = "refs/for/" + checkoutBranch; - - List<RemoteConfig> remoteConfigs = RemoteConfig.getAllRemoteConfigs(config); - for (RemoteConfig remoteConfig : remoteConfigs) - { - if ("origin".equals(remoteConfig.getName())) - { - List<RefSpec> pushRefSpecs = remoteConfig.getPushRefSpecs(); - if (!hasGerritPushRefSpec(pushRefSpecs, gerritQueue)) - { - RefSpec refSpec = new RefSpec("HEAD:" + gerritQueue); - Progress.log().addLine("Adding push ref spec: " + refSpec); - - remoteConfig.addPushRefSpec(refSpec); - remoteConfig.update(config); - changed = true; - } - - break; - } - } - - if (changed) - { - config.save(); - } - - Map<String, Ref> allRefs = repository.getAllRefs(); - if (!allRefs.containsKey("refs/heads/" + checkoutBranch)) - { - { - CreateBranchCommand command = git.branchCreate(); - command.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM); - command.setName(checkoutBranch); - command.setStartPoint("refs/remotes/origin/" + checkoutBranch); - - command.call(); - } - - { - CheckoutCommand command = git.checkout(); - command.setName(checkoutBranch); - - command.call(); - } - - { - ResetCommand command = git.reset(); - command.setMode(ResetType.HARD); - - command.call(); - } - } - } - finally - { - if (repository != null) - { - repository.close(); - } - } - } - } - - private static boolean hasWorkingDirectory(Git git) throws GitAPIException - { - try - { - StatusCommand statusCommand = git.status(); - statusCommand.call(); - return true; - } - catch (NoWorkTreeException ex) - { - return false; - } - catch (GitAPIException ex) - { - throw ex; - } - } - - private static boolean hasGerritPushRefSpec(List<RefSpec> pushRefSpecs, String gerritQueue) - { - for (RefSpec refSpec : pushRefSpecs) - { - if (refSpec.getDestination().equals(gerritQueue)) - { - return true; - } - } - - return false; - } - - /** - * @author Eike Stepper - */ - private static final class ProgressLogWrapper implements ProgressMonitor - { - public void update(int completed) - { - } - - public void start(int totalTasks) - { - } - - public boolean isCancelled() - { - return Progress.log().isCancelled(); - } - - public void endTask() - { - } - - public void beginTask(String title, int totalWork) - { - Progress.log().addLine(title); - } - } + // private static final SetupContext CONTEXT = Activator.getDefault(); + // + // public static void init() throws Exception + // { + // Setup setup = CONTEXT.getSetup(); + // Branch branch = setup.getBranch(); + // String userName = setup.getPreferences().getUserName(); + // + // for (GitClone gitClone : branch.getGitClones()) + // { + // File workDir = CONTEXT.getWorkDir(gitClone); + // + // Repository repository = null; + // Git git = null; + // + // try + // { + // boolean needsClone = true; + // if (workDir.isDirectory()) + // { + // Progress.log().addLine("Opening Git clone " + workDir); + // git = Git.open(workDir); + // if (hasWorkingDirectory(git)) + // { + // needsClone = false; + // } + // else + // { + // Files.rename(workDir); + // } + // } + // + // String checkoutBranch = gitClone.getCheckoutBranch(); + // if (needsClone) + // { + // URI baseURI = URI.createURI(gitClone.getRemoteURI()); + // String remote = URI.createHierarchicalURI(baseURI.scheme(), userName + "@" + baseURI.authority(), + // baseURI.device(), baseURI.segments(), baseURI.query(), baseURI.fragment()).toString(); + // Progress.log().addLine("Cloning Git repo " + remote + " to " + workDir); + // + // CloneCommand command = Git.cloneRepository(); + // command.setNoCheckout(true); + // command.setURI(remote); + // command.setRemote("origin"); + // command.setBranchesToClone(Collections.singleton(checkoutBranch)); + // command.setDirectory(workDir); + // command.setTimeout(10); + // command.setProgressMonitor(new ProgressLogWrapper()); + // + // git = command.call(); + // } + // + // repository = git.getRepository(); + // StoredConfig config = repository.getConfig(); + // + // boolean changed = false; + // if (OS.INSTANCE.isLineEndingConversionNeeded()) + // { + // changed = true; + // config.setEnum(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, AutoCRLF.TRUE); + // } + // + // String gerritQueue = "refs/for/" + checkoutBranch; + // + // List<RemoteConfig> remoteConfigs = RemoteConfig.getAllRemoteConfigs(config); + // for (RemoteConfig remoteConfig : remoteConfigs) + // { + // if ("origin".equals(remoteConfig.getName())) + // { + // List<RefSpec> pushRefSpecs = remoteConfig.getPushRefSpecs(); + // if (!hasGerritPushRefSpec(pushRefSpecs, gerritQueue)) + // { + // RefSpec refSpec = new RefSpec("HEAD:" + gerritQueue); + // Progress.log().addLine("Adding push ref spec: " + refSpec); + // + // remoteConfig.addPushRefSpec(refSpec); + // remoteConfig.update(config); + // changed = true; + // } + // + // break; + // } + // } + // + // if (changed) + // { + // config.save(); + // } + // + // Map<String, Ref> allRefs = repository.getAllRefs(); + // if (!allRefs.containsKey("refs/heads/" + checkoutBranch)) + // { + // { + // CreateBranchCommand command = git.branchCreate(); + // command.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM); + // command.setName(checkoutBranch); + // command.setStartPoint("refs/remotes/origin/" + checkoutBranch); + // + // command.call(); + // } + // + // { + // CheckoutCommand command = git.checkout(); + // command.setName(checkoutBranch); + // + // command.call(); + // } + // + // { + // ResetCommand command = git.reset(); + // command.setMode(ResetType.HARD); + // + // command.call(); + // } + // } + // } + // finally + // { + // if (repository != null) + // { + // repository.close(); + // } + // } + // } + // } + // + // private static boolean hasWorkingDirectory(Git git) throws GitAPIException + // { + // try + // { + // StatusCommand statusCommand = git.status(); + // statusCommand.call(); + // return true; + // } + // catch (NoWorkTreeException ex) + // { + // return false; + // } + // catch (GitAPIException ex) + // { + // throw ex; + // } + // } + // + // private static boolean hasGerritPushRefSpec(List<RefSpec> pushRefSpecs, String gerritQueue) + // { + // for (RefSpec refSpec : pushRefSpecs) + // { + // if (refSpec.getDestination().equals(gerritQueue)) + // { + // return true; + // } + // } + // + // return false; + // } + // + // /** + // * @author Eike Stepper + // */ + // private static final class ProgressLogWrapper implements ProgressMonitor + // { + // public void update(int completed) + // { + // } + // + // public void start(int totalTasks) + // { + // } + // + // public boolean isCancelled() + // { + // return Progress.log().isCancelled(); + // } + // + // public void endTask() + // { + // } + // + // public void beginTask(String title, int totalWork) + // { + // Progress.log().addLine(title); + // } + // } } diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/P2.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/P2.java index 5d28d0f1ab..71bf67be1d 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/P2.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/P2.java @@ -10,37 +10,29 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.setup.P2Repository; -import org.eclipse.emf.cdo.releng.setup.Setup; -import org.eclipse.emf.cdo.releng.setup.helper.Progress; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.p2.ui.ProvisioningUI; - -import java.net.URI; - /** * @author Eike Stepper */ +@Deprecated public class P2 { - private static final SetupContext CONTEXT = Activator.getDefault(); - - public static void registerUpdateLocations() throws Exception - { - Setup setup = CONTEXT.getSetup(); - for (P2Repository p2Repository : setup.getUpdateLocations()) - { - URI location = new URI(p2Repository.getUrl()); - Progress.log().addLine("Registering update location: " + location); - addRepository(location); - } - } - - private static void addRepository(URI location) throws Exception - { - ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI(); - provisioningUI.loadMetadataRepository(location, false, new NullProgressMonitor()); - provisioningUI.loadArtifactRepository(location, false, new NullProgressMonitor()); - } + // private static final SetupContext CONTEXT = Activator.getDefault(); + // + // public static void registerUpdateLocations() throws Exception + // { + // Setup setup = CONTEXT.getSetup(); + // for (P2Repository p2Repository : setup.getUpdateLocations()) + // { + // URI location = new URI(p2Repository.getUrl()); + // Progress.log().log("Registering update location: " + location); + // addRepository(location); + // } + // } + // + // private static void addRepository(URI location) throws Exception + // { + // ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI(); + // provisioningUI.loadMetadataRepository(location, false, new NullProgressMonitor()); + // provisioningUI.loadArtifactRepository(location, false, new NullProgressMonitor()); + // } } diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Prefs.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Prefs.java index 1dcb39bce7..1c6e90dc25 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Prefs.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Prefs.java @@ -10,89 +10,78 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.setup.Branch; -import org.eclipse.emf.cdo.releng.setup.Preferences; -import org.eclipse.emf.cdo.releng.setup.Project; -import org.eclipse.emf.cdo.releng.setup.Setup; -import org.eclipse.emf.cdo.releng.setup.ToolInstallation; -import org.eclipse.emf.cdo.releng.setup.ToolPreference; -import org.eclipse.emf.cdo.releng.setup.helper.Progress; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.ui.PlatformUI; - /** * @author Eike Stepper */ +@Deprecated public final class Prefs { - private static final SetupContext CONTEXT = Activator.getDefault(); - - private static final IEclipsePreferences ROOT = Platform.getPreferencesService().getRootNode(); - - public static void initEarly() throws Exception - { - Setup setup = CONTEXT.getSetup(); - Branch branch = setup.getBranch(); - Project project = branch.getProject(); - - final String name = project.getName() + ("master".equals(branch.getName()) ? "" : " " + branch.getName()); - PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell().getDisplay().syncExec(new Runnable() - { - public void run() - { - set("instance/org.eclipse.ui.ide/WORKSPACE_NAME", name); - } - }); - - set("instance/org.eclipse.ui.workbench/RUN_IN_BACKGROUND", "true"); - } - - public static void initLate() throws Exception - { - Setup setup = CONTEXT.getSetup(); - Branch branch = setup.getBranch(); - Project project = branch.getProject(); - - Preferences preferences = setup.getPreferences(); - init(preferences); - init(branch); - init(project); - } - - private static void init(ToolInstallation preferenceHolder) - { - for (ToolPreference toolPreference : preferenceHolder.getToolPreferences()) - { - init(toolPreference); - } - } - - private static void init(ToolPreference toolPreference) - { - String key = toolPreference.getKey(); - if (key.startsWith("/")) - { - key = key.substring(1); - } - - String value = toolPreference.getValue(); - set(key, value); - } - - public static void set(String key, String value) - { - org.osgi.service.prefs.Preferences node = ROOT; - - String[] segments = key.split("/"); - for (int i = 0; i < segments.length - 1; i++) - { - String segment = segments[i]; - node = node.node(segment); - } - - Progress.log().addLine("Setting preference " + key + " = " + value); - node.put(segments[segments.length - 1], value); - } + // private static final SetupContext CONTEXT = Activator.getDefault(); + // + // private static final org.osgi.service.prefs.Preferences ROOT = Platform.getPreferencesService().getRootNode(); + // + // public static void initEarly() throws Exception + // { + // Setup setup = CONTEXT.getSetup(); + // Branch branch = setup.getBranch(); + // Project project = branch.getProject(); + // + // final String name = project.getName() + ("master".equals(branch.getName()) ? "" : " " + branch.getName()); + // PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell().getDisplay().syncExec(new Runnable() + // { + // public void run() + // { + // set("instance/org.eclipse.ui.ide/WORKSPACE_NAME", name); + // } + // }); + // + // set("instance/org.eclipse.ui.workbench/RUN_IN_BACKGROUND", "true"); + // } + // + // public static void initLate() throws Exception + // { + // Setup setup = CONTEXT.getSetup(); + // Branch branch = setup.getBranch(); + // Project project = branch.getProject(); + // + // Preferences preferences = setup.getPreferences(); + // init(project); + // init(branch); + // init(preferences); + // } + // + // private static void init(ToolInstallation preferenceHolder) + // { + // for (ToolPreference toolPreference : preferenceHolder.getToolPreferences()) + // { + // init(toolPreference); + // } + // } + // + // private static void init(ToolPreference toolPreference) + // { + // String key = toolPreference.getKey(); + // if (key.startsWith("/")) + // { + // key = key.substring(1); + // } + // + // String value = toolPreference.getValue(); + // set(key, value); + // } + // + // public static void set(String key, String value) + // { + // org.osgi.service.prefs.Preferences node = ROOT; + // + // String[] segments = key.split("/"); + // for (int i = 0; i < segments.length - 1; i++) + // { + // String segment = segments[i]; + // node = node.node(segment); + // } + // + // Progress.log().addLine("Setting preference " + key + " = " + value); + // node.put(segments[segments.length - 1], value); + // } } diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/SetupContext.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/SetupContext.java index f51bb86438..4dff5ff73b 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/SetupContext.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/SetupContext.java @@ -10,7 +10,6 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.setup.GitClone; import org.eclipse.emf.cdo.releng.setup.Setup; import java.io.File; @@ -18,6 +17,7 @@ import java.io.File; /** * @author Eike Stepper */ +@Deprecated public interface SetupContext { public File getLogFile(); @@ -30,9 +30,9 @@ public interface SetupContext public File getEclipseDir(); - public File getGitDir(); - - public File getWorkDir(GitClone clone); + // public File getGitDir(); + // + // public File getWorkDir(GitClone clone); public File getWorkspaceDir(); diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/SetupIDE.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/SetupIDE.java index 8cff533693..a90c3a4034 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/SetupIDE.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/SetupIDE.java @@ -10,149 +10,136 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.setup.helper.OS; -import org.eclipse.emf.cdo.releng.setup.helper.ProgressLog; -import org.eclipse.emf.cdo.releng.setup.helper.ProgressLogRunnable; -import org.eclipse.emf.cdo.releng.setup.ui.ProgressLogDialog; - -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -import java.io.File; -import java.util.Collections; -import java.util.List; - /** * @author Eike Stepper */ +@Deprecated public final class SetupIDE { - private static final SetupContext CONTEXT = Activator.getDefault(); - - private static final IWorkbench WORKBENCH = PlatformUI.getWorkbench(); - - private static final int INITIAL = 0; - - private static final int DONE = 100; - - private static int state; - - public static void run() throws Exception - { - state = readState(); - if (state == DONE) - { - return; - } - - IWorkbenchWindow window = WORKBENCH.getWorkbenchWindows()[0]; - run(window); - } - - private static void run(IWorkbenchWindow window) - { - final Shell shell = window.getShell(); - shell.getDisplay().asyncExec(new Runnable() - { - public void run() - { - ProgressLogDialog.run(shell, CONTEXT.getLogFile(), "Setting up IDE", new ProgressLogRunnable() - { - public boolean run(ProgressLog log) throws Exception - { - boolean autoBuilding = Buckminster.disableAutoBuilding(); - - try - { - return SetupIDE.run(log); - } - finally - { - Buckminster.restoreAutoBuilding(autoBuilding); - } - } - }); - } - }); - } - - private static boolean run(ProgressLog log) throws Exception - { - boolean restart = false; - if (state < 1) - { - P2.registerUpdateLocations(); - saveState(1); - } - - if (state < 2) - { - Prefs.initEarly(); - saveState(2); - } - - if (state < 3) - { - GitClones.init(); - saveState(3); - } - - if (state < 4) - { - Buckminster.importBaseline(); - saveState(4); - } - - if (state < 5) - { - Buckminster.importTarget(); - saveState(5); - } - - if (state < 6) - { - Buckminster.importMSpec(); - saveState(6); - restart = true; - } - - if (state < 7) - { - WorkingSets.init(); - saveState(7); - } - - if (state < DONE) - { - Prefs.initLate(); - saveState(DONE); - } - - Buckminster.restoreAutoBuilding(true); - return restart; - } - - private static void saveState(int state) - { - File stateFile = new File(Activator.getDefault().getStateLocation().toOSString(), "state.txt"); - OS.INSTANCE.writeText(stateFile, Collections.singletonList(Integer.toString(state))); - } - - private static int readState() - { - File stateFile = new File(Activator.getDefault().getStateLocation().toOSString(), "state.txt"); - if (stateFile.exists()) - { - List<String> lines = OS.INSTANCE.readText(stateFile); - if (!lines.isEmpty()) - { - String line = lines.get(0); - return Integer.parseInt(line); - } - } - - return INITIAL; - } + // private static final SetupContext CONTEXT = Activator.getDefault(); + // + // private static final IWorkbench WORKBENCH = PlatformUI.getWorkbench(); + // + // private static final int INITIAL = 0; + // + // private static final int DONE = 100; + // + // private static int state; + // + // public static void run() throws Exception + // { + // state = readState(); + // if (state == DONE) + // { + // return; + // } + // + // IWorkbenchWindow window = WORKBENCH.getWorkbenchWindows()[0]; + // run(window); + // } + // + // private static void run(IWorkbenchWindow window) + // { + // final Shell shell = window.getShell(); + // shell.getDisplay().asyncExec(new Runnable() + // { + // public void run() + // { + // ProgressLogDialog.run(shell, CONTEXT.getLogFile(), "Setting up IDE", new ProgressLogRunnable() + // { + // public boolean run(ProgressLog log) throws Exception + // { + // boolean autoBuilding = Buckminster.disableAutoBuilding(); + // + // try + // { + // return SetupIDE.run(log); + // } + // finally + // { + // Buckminster.restoreAutoBuilding(autoBuilding); + // } + // } + // }); + // } + // }); + // } + // + // private static boolean run(ProgressLog log) throws Exception + // { + // boolean restart = false; + // if (state < 1) + // { + // P2.registerUpdateLocations(); + // saveState(1); + // } + // + // if (state < 2) + // { + // Prefs.initEarly(); + // saveState(2); + // } + // + // if (state < 3) + // { + // GitClones.init(); + // saveState(3); + // } + // + // if (state < 4) + // { + // Buckminster.importBaseline(); + // saveState(4); + // } + // + // if (state < 5) + // { + // Buckminster.importTarget(); + // saveState(5); + // } + // + // if (state < 6) + // { + // Buckminster.importMSpec(); + // saveState(6); + // restart = true; + // } + // + // if (state < 7) + // { + // WorkingSets.init(); + // saveState(7); + // } + // + // if (state < DONE) + // { + // Prefs.initLate(); + // saveState(DONE); + // } + // + // Buckminster.restoreAutoBuilding(true); + // return restart; + // } + // + // private static void saveState(int state) + // { + // File stateFile = new File(Activator.getDefault().getStateLocation().toOSString(), "state.txt"); + // OS.INSTANCE.writeText(stateFile, Collections.singletonList(Integer.toString(state))); + // } + // + // private static int readState() + // { + // File stateFile = new File(Activator.getDefault().getStateLocation().toOSString(), "state.txt"); + // if (stateFile.exists()) + // { + // List<String> lines = OS.INSTANCE.readText(stateFile); + // if (!lines.isEmpty()) + // { + // String line = lines.get(0); + // return Integer.parseInt(line); + // } + // } + // + // return INITIAL; + // } } diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Variables.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Variables.java index 97d2078d21..08d4f985a7 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Variables.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/Variables.java @@ -10,38 +10,33 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.setup.helper.Progress; - -import org.eclipse.core.variables.IStringVariableManager; -import org.eclipse.core.variables.IValueVariable; -import org.eclipse.core.variables.VariablesPlugin; - /** * @author Eike Stepper */ +@Deprecated public final class Variables { - public static void set(String name, String description, String value) throws Exception - { - IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); - IValueVariable variable = manager.getValueVariable(name); - if (variable == null) - { - variable = manager.newValueVariable(name, description); - manager.addVariables(new IValueVariable[] { variable }); - } - - String oldDescription = variable.getDescription(); - if (!description.equals(oldDescription)) - { - variable.setDescription(description); - } - - String oldValue = variable.getValue(); - if (!value.equals(oldValue)) - { - Progress.log().addLine("Setting string substitution variable " + name + " = " + value); - variable.setValue(value); - } - } + // public static void set(String name, String description, String value) throws Exception + // { + // IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); + // IValueVariable variable = manager.getValueVariable(name); + // if (variable == null) + // { + // variable = manager.newValueVariable(name, description); + // manager.addVariables(new IValueVariable[] { variable }); + // } + // + // String oldDescription = variable.getDescription(); + // if (!description.equals(oldDescription)) + // { + // variable.setDescription(description); + // } + // + // String oldValue = variable.getValue(); + // if (!value.equals(oldValue)) + // { + // Progress.log().addLine("Setting string substitution variable " + name + " = " + value); + // variable.setValue(value); + // } + // } } diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/WorkingSets.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/WorkingSets.java index e78ef47111..73c2068a08 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/WorkingSets.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/WorkingSets.java @@ -10,72 +10,54 @@ */ package org.eclipse.emf.cdo.releng.setup.ide; -import org.eclipse.emf.cdo.releng.workingsets.WorkingSetGroup; -import org.eclipse.emf.cdo.releng.workingsets.util.WorkingSetsUtil; - -import org.eclipse.emf.ecore.resource.Resource; - -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -import java.io.IOException; -import java.lang.reflect.Method; - /** * @author Eike Stepper */ +@Deprecated public final class WorkingSets { - private static final SetupContext CONTEXT = Activator.getDefault(); - - private static final IWorkbench WORKBENCH = PlatformUI.getWorkbench(); - - private static final String JAVA_PACKAGE_EXPLORER_VIEW_ID = "org.eclipse.jdt.ui.PackageExplorer"; - - public static void init() throws IOException - { - WorkingSetGroup workingSetGroup = CONTEXT.getSetup().getBranch().getProject().getWorkingSetGroup(); - if (workingSetGroup != null) - { - initPackageExplorer(); - - WorkingSetGroup defaultWorkingSetGroup = WorkingSetsUtil.getWorkingSetGroup(); - Resource resource = defaultWorkingSetGroup.eResource(); - resource.getContents().set(0, workingSetGroup); - resource.save(null); - } - } - - private static void initPackageExplorer() - { - IWorkbenchWindow workbenchWindow = WORKBENCH.getWorkbenchWindows()[0]; - for (final IViewReference viewReference : workbenchWindow.getActivePage().getViewReferences()) - { - if (JAVA_PACKAGE_EXPLORER_VIEW_ID.equals(viewReference.getId())) - { - workbenchWindow.getShell().getDisplay().asyncExec(new Runnable() - { - public void run() - { - IViewPart view = viewReference.getView(false); - if (view != null) - { - try - { - Method method = view.getClass().getMethod("rootModeChanged", int.class); - method.invoke(view, 2); - } - catch (Exception ex) - { - Activator.log(ex); - } - } - } - }); - } - } - } + // private static final SetupContext CONTEXT = Activator.getDefault(); + // + // private static final IWorkbench WORKBENCH = PlatformUI.getWorkbench(); + // + // private static final String PACKAGE_EXPLORER_ID = "org.eclipse.jdt.ui.PackageExplorer"; + // + // public static void init() throws IOException + // { + // WorkingSetGroup workingSetGroup = CONTEXT.getSetup().getBranch().getProject().getWorkingSetGroup(); + // if (workingSetGroup != null) + // { + // initPackageExplorer(); + // + // WorkingSetGroup defaultWorkingSetGroup = WorkingSetsUtil.getWorkingSetGroup(); + // Resource resource = defaultWorkingSetGroup.eResource(); + // resource.getContents().set(0, workingSetGroup); + // resource.save(null); + // } + // } + // + // private static void initPackageExplorer() + // { + // final IWorkbenchWindow workbenchWindow = WORKBENCH.getWorkbenchWindows()[0]; + // workbenchWindow.getShell().getDisplay().asyncExec(new Runnable() + // { + // public void run() + // { + // try + // { + // IViewPart view = workbenchWindow.getActivePage().showView(PACKAGE_EXPLORER_ID, null, + // IWorkbenchPage.VIEW_CREATE); + // if (view != null) + // { + // Method method = view.getClass().getMethod("rootModeChanged", int.class); + // method.invoke(view, 2); + // } + // } + // catch (Exception ex) + // { + // Activator.log(ex); + // } + // } + // }); + // } } diff --git a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/actions/BuckyAction.java b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/actions/BuckyAction.java index d0b0858b01..0f756dbf5e 100644 --- a/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/actions/BuckyAction.java +++ b/plugins/org.eclipse.emf.cdo.releng.setup.ide/src/org/eclipse/emf/cdo/releng/setup/ide/actions/BuckyAction.java @@ -10,13 +10,6 @@ */ package org.eclipse.emf.cdo.releng.setup.ide.actions; -import org.eclipse.emf.cdo.releng.setup.helper.ProgressLog; -import org.eclipse.emf.cdo.releng.setup.helper.ProgressLogRunnable; -import org.eclipse.emf.cdo.releng.setup.ide.Activator; -import org.eclipse.emf.cdo.releng.setup.ide.Buckminster; -import org.eclipse.emf.cdo.releng.setup.ide.SetupContext; -import org.eclipse.emf.cdo.releng.setup.ui.ProgressLogDialog; - import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; @@ -27,8 +20,6 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate; */ public class BuckyAction implements IWorkbenchWindowActionDelegate { - private static final SetupContext CONTEXT = Activator.getDefault(); - private IWorkbenchWindow window; public BuckyAction() @@ -50,22 +41,22 @@ public class BuckyAction implements IWorkbenchWindowActionDelegate public void run(IAction action) { - ProgressLogDialog.run(window.getShell(), CONTEXT.getLogFile(), "Importing mspec", new ProgressLogRunnable() - { - public boolean run(ProgressLog log) throws Exception - { - boolean autoBuilding = Buckminster.disableAutoBuilding(); - - try - { - Buckminster.importMSpec(); - return true; - } - finally - { - Buckminster.restoreAutoBuilding(autoBuilding); - } - } - }); + // ProgressLogDialog.run(window.getShell(), CONTEXT.getLogFile(), "Importing mspec", new ProgressLogRunnable() + // { + // public boolean run(ProgressLog log) throws Exception + // { + // boolean autoBuilding = Buckminster.disableAutoBuilding(); + // + // try + // { + // Buckminster.importMSpec(); + // return true; + // } + // finally + // { + // Buckminster.restoreAutoBuilding(autoBuilding); + // } + // } + // }); } } |