Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2009-09-24 11:11:01 -0400
committerAndrew Niefer2009-09-24 11:11:01 -0400
commitaf1d44698b2dcdfdcfe479d4bceb3256e96e5bac (patch)
tree26f79e73e2719bd40435cbe45c423de9c899ee20 /bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse
parent151446f6878d2c293e741f41e0adbb3886f3f2d8 (diff)
downloadrt.equinox.p2-af1d44698b2dcdfdcfe479d4bceb3256e96e5bac.tar.gz
rt.equinox.p2-af1d44698b2dcdfdcfe479d4bceb3256e96e5bac.tar.xz
rt.equinox.p2-af1d44698b2dcdfdcfe479d4bceb3256e96e5bac.zip
bug 290323 - remove IUs from repo
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RemoveIUTask.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RemoveIUTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RemoveIUTask.java
new file mode 100644
index 000000000..ccf1032b1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RemoveIUTask.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+
+import java.util.Iterator;
+import org.apache.tools.ant.BuildException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.internal.provisional.p2.query.Collector;
+import org.eclipse.equinox.internal.provisional.p2.query.Query;
+import org.eclipse.equinox.p2.internal.repository.tools.AbstractApplication;
+import org.eclipse.equinox.p2.internal.repository.tools.Messages;
+import org.eclipse.osgi.util.NLS;
+
+public class RemoveIUTask extends AbstractRepositoryTask {
+
+ public RemoveIUTask() {
+ application = new AbstractApplication() {
+ public IStatus run(IProgressMonitor monitor) {
+ return null;
+ }
+
+ public IMetadataRepository getCompositeMetadataRepository() {
+ return destinationMetadataRepository;
+ }
+
+ public IArtifactRepository getCompositeArtifactRepository() {
+ return destinationArtifactRepository;
+ }
+ };
+ }
+
+ public void execute() throws BuildException {
+ try {
+ if (iuTasks == null || iuTasks.isEmpty())
+ return; //nothing to do
+
+ application.initializeRepos(null);
+ if (application.getCompositeMetadataRepository() == null)
+ throw new BuildException(Messages.AbstractApplication_no_valid_destinations); //need a repo
+
+ IMetadataRepository repository = application.getCompositeMetadataRepository();
+ IArtifactRepository artifacts = application.getCompositeArtifactRepository();
+
+ for (Iterator iter = iuTasks.iterator(); iter.hasNext();) {
+ IUDescription iu = (IUDescription) iter.next();
+ Query iuQuery = iu.createQuery();
+
+ Collector collector = new Collector();
+ repository.query(iuQuery, collector, null);
+
+ if (collector.isEmpty())
+ getProject().log(NLS.bind(Messages.AbstractRepositoryTask_unableToFind, iu.toString()));
+ else if (repository.removeInstallableUnits(iuQuery, null) && artifacts != null) {
+ for (Iterator iterator = collector.iterator(); iterator.hasNext();) {
+ IInstallableUnit unit = (IInstallableUnit) iterator.next();
+ IArtifactKey[] keys = unit.getArtifacts();
+ for (int i = 0; i < keys.length; i++) {
+ artifacts.removeDescriptor(keys[i]);
+ }
+ }
+ }
+ }
+ } catch (ProvisionException e) {
+ throw new BuildException(e);
+ }
+ }
+}

Back to the top