Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2fb1f2b7dd7efc5994f2fea922c61f0debc957e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
 * 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 org.eclipse.equinox.p2.core.ProvisionException;

import org.apache.tools.ant.BuildException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.internal.repository.tools.CompositeRepositoryApplication;

public class CompositeRepositoryTask extends AbstractRepositoryTask {

	public CompositeRepositoryTask() {
		application = new CompositeRepositoryApplication();
	}

	/* (non-Javadoc)
	 * @see org.apache.tools.ant.Task#execute()
	 */
	public void execute() throws BuildException {
		try {
			IStatus result = application.run(null);
			if (result.matches(IStatus.ERROR)) {
				throw new BuildException(TaskHelper.statusToString(result, null).toString());
			}
		} catch (ProvisionException e) {
			throw new BuildException(e);
		}
	}

	/*
	 * Add the listed repositories to the composite repository
	 */
	public void addConfiguredAdd(RepositoryList list) {
		for (DestinationRepository repo : list.getRepositoryList()) {
			((CompositeRepositoryApplication) application).addChild(repo.getDescriptor());
		}
	}

	/*	
	 * Remove the listed repositories from the composite repository
	 */
	public void addConfiguredRemove(RepositoryList list) {
		for (DestinationRepository repo : list.getRepositoryList()) {
			((CompositeRepositoryApplication) application).removeChild(repo.getDescriptor());
		}
	}

	/*
	 * Set whether the task should fail if the repository already exists
	 */
	public void setFailOnExists(boolean value) {
		((CompositeRepositoryApplication) application).setFailOnExists(value);
	}

	public void setValidate(String value) {
		((CompositeRepositoryApplication) application).setComparator(value);
	}
}

Back to the top