Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-01-13 12:29:41 -0500
committerPascal Rapicault2010-01-13 12:29:41 -0500
commit18189f0d42f7375660762dc6c885cf31683ae562 (patch)
tree17775d847bed9a33f3c68b74db2df75a2139c0bc /bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse
parentc363f2984a09b73c422e38f4556fd3b23eafe958 (diff)
downloadrt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.gz
rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.xz
rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.zip
Merging api branch back to HEADv20100113
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/AbstractRepositoryTask.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AntMirrorLog.java106
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeArtifactRepositoryTask.java121
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/IUDescription.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorArtifactsTask.java180
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorMetadataTask.java95
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RemoveIUTask.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ValidateTask.java73
15 files changed, 711 insertions, 102 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
index 372a2929f..083755166 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2010 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
@@ -10,10 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.tasks;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query;
-
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
@@ -22,17 +18,18 @@ import org.apache.tools.ant.*;
import org.apache.tools.ant.types.FileSet;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.URIUtil;
-import org.eclipse.equinox.internal.p2.artifact.repository.ant.AntMirrorLog;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.internal.repository.tools.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.osgi.util.NLS;
public abstract class AbstractRepositoryTask extends Task {
protected static final String ANT_PREFIX = "${"; //$NON-NLS-1$
protected AbstractApplication application;
- protected List iuTasks = new ArrayList();
- protected List sourceRepos = new ArrayList();
- protected List destinations = new ArrayList();
+ protected List<IUDescription> iuTasks = new ArrayList<IUDescription>();
+ protected List<FileSet> sourceRepos = new ArrayList<FileSet>();
+ protected List<DestinationRepository> destinations = new ArrayList<DestinationRepository>();
protected void addMetadataSourceRepository(URI repoLocation) {
RepositoryDescriptor source = new RepositoryDescriptor();
@@ -105,13 +102,11 @@ public abstract class AbstractRepositoryTask extends Task {
* Add source repositories to mirror from
*/
public void addConfiguredSource(RepositoryList sourceList) {
- for (Iterator iter = sourceList.getRepositoryList().iterator(); iter.hasNext();) {
- DestinationRepository repo = (DestinationRepository) iter.next();
+ for (DestinationRepository repo : sourceList.getRepositoryList()) {
application.addSource(repo.getDescriptor());
}
- for (Iterator iter = sourceList.getFileSetList().iterator(); iter.hasNext();) {
- FileSet fileSet = (FileSet) iter.next();
+ for (FileSet fileSet : sourceList.getFileSetList()) {
sourceRepos.add(fileSet);
// Added to the application later through prepareSourceRepos
}
@@ -124,14 +119,15 @@ public abstract class AbstractRepositoryTask extends Task {
protected void prepareSourceRepos() {
if (sourceRepos == null || sourceRepos.isEmpty())
return;
- for (Iterator iter = sourceRepos.iterator(); iter.hasNext();) {
+ for (Iterator<FileSet> iter = sourceRepos.iterator(); iter.hasNext();) {
RepositoryFileSet fileset = (RepositoryFileSet) iter.next();
if (fileset.getRepoLocation() != null) {
- //TODO depreciate
if (!fileset.getRepoLocation().startsWith(ANT_PREFIX)) {
- addArtifactSourceRepository(fileset.getRepoLocationURI());
- addMetadataSourceRepository(fileset.getRepoLocationURI());
+ if (fileset.isArtifact())
+ addArtifactSourceRepository(fileset.getRepoLocationURI());
+ if (fileset.isMetadata())
+ addMetadataSourceRepository(fileset.getRepoLocationURI());
}
} else if (fileset.getDir() != null) {
DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
@@ -160,22 +156,21 @@ public abstract class AbstractRepositoryTask extends Task {
sourceRepos.clear();
}
- protected List prepareIUs() {
+ protected List<IInstallableUnit> prepareIUs() {
if (iuTasks == null || iuTasks.isEmpty())
return null;
IMetadataRepository repository = application.getCompositeMetadataRepository();
- List result = new ArrayList();
- for (Iterator iter = iuTasks.iterator(); iter.hasNext();) {
- IUDescription iu = (IUDescription) iter.next();
- Query iuQuery = iu.createQuery();
- Collector collector = new Collector();
+ List<IInstallableUnit> result = new ArrayList<IInstallableUnit>();
+ for (IUDescription iu : iuTasks) {
+ IQuery<IInstallableUnit> iuQuery = iu.createQuery();
- repository.query(iuQuery, collector, null);
+ Iterator<IInstallableUnit> queryResult = repository.query(iuQuery, null).iterator();
- if (iu.isRequired() && collector.isEmpty())
+ if (iu.isRequired() && !queryResult.hasNext())
throw new BuildException(NLS.bind(Messages.AbstractRepositoryTask_unableToFind, iu.toString()));
- result.addAll(collector.toCollection());
+ while (queryResult.hasNext())
+ result.add(queryResult.next());
}
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AntMirrorLog.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AntMirrorLog.java
new file mode 100644
index 000000000..5c7d04d08
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AntMirrorLog.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.internal.repository.mirroring.IArtifactMirrorLog;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.artifact.repository.Messages;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+
+public class AntMirrorLog implements IArtifactMirrorLog {
+
+ private boolean consoleMessage = false;
+ private Method log;
+ private Object task;
+
+ public AntMirrorLog(Object task) throws NoSuchMethodException {
+ this.task = task;
+ try {
+ log = task.getClass().getMethod("log", new Class[] {String.class, int.class}); //$NON-NLS-1$
+ } catch (SecurityException e) {
+ exceptionOccurred(null, e);
+ }
+ }
+
+ public void log(IArtifactDescriptor descriptor, IStatus status) {
+ log(descriptor.toString(), status.getSeverity());
+ log(status);
+ }
+
+ public void log(IStatus status) {
+ int severity = status.getSeverity();
+ // Log the status message
+ log(status.getMessage(), severity);
+ // Log the exception if applicable
+ if (status.getException() != null)
+ log(status.getException().getMessage(), severity);
+
+ // Log any children of this status
+ IStatus[] nestedStatus = status.getChildren();
+ if (nestedStatus != null)
+ for (int i = 0; i < nestedStatus.length; i++)
+ log(nestedStatus[i]);
+ }
+
+ public void close() {
+ // nothing to do here
+ }
+
+ /*
+ * Log a message to the Ant Task
+ */
+ private void log(String message, int statusSeverity) {
+ try {
+ log.invoke(task, new Object[] {message, new Integer(mapLogLevels(statusSeverity))});
+ } catch (IllegalArgumentException e) {
+ exceptionOccurred(message, e);
+ } catch (IllegalAccessException e) {
+ exceptionOccurred(message, e);
+ } catch (InvocationTargetException e) {
+ exceptionOccurred(message, e);
+ }
+ }
+
+ /*
+ * Show an error message if this the first time, and print status messages.
+ */
+ private void exceptionOccurred(String message, Exception e) {
+ if (!consoleMessage) {
+ System.err.println(Messages.MirrorLog_Exception_Occurred);
+ e.printStackTrace(System.err);
+ System.err.println(Messages.MirrorLog_Console_Log);
+ consoleMessage = true;
+ }
+ if (message != null)
+ System.out.println(message);
+ }
+
+ /**
+ * Copied from AntLogAdapter in pde build.
+ */
+ private int mapLogLevels(int iStatusLevel) {
+ switch (iStatusLevel) {
+ case IStatus.ERROR :
+ return 0;
+ case IStatus.OK :
+ return 2;
+ case IStatus.INFO :
+ return 2;
+ case IStatus.WARNING :
+ return 1;
+ default :
+ return 1;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java
index f1e8e9e9c..4560fe96f 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java
@@ -10,13 +10,18 @@
*******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.tasks;
-import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
import org.apache.tools.ant.BuildException;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.internal.repository.tools.CompositeRepositoryApplication;
+import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
public class CompositeRepositoryTask extends AbstractRepositoryTask {
+ private static String COMPOSITE_REMOVE = "p2.composite.artifact.repository.remove"; //$NON-NLS-1$
+ private static String COMPOSITE_ADD = "p2.composite.artifact.repository.add"; //$NON-NLS-1$
public CompositeRepositoryTask() {
application = new CompositeRepositoryApplication();
@@ -40,8 +45,7 @@ public class CompositeRepositoryTask extends AbstractRepositoryTask {
* Add the listed repositories to the composite repository
*/
public void addConfiguredAdd(RepositoryList list) {
- for (Iterator iter = list.getRepositoryList().iterator(); iter.hasNext();) {
- DestinationRepository repo = (DestinationRepository) iter.next();
+ for (DestinationRepository repo : list.getRepositoryList()) {
((CompositeRepositoryApplication) application).addChild(repo.getDescriptor());
}
}
@@ -50,8 +54,7 @@ public class CompositeRepositoryTask extends AbstractRepositoryTask {
* Remove the listed repositories from the composite repository
*/
public void addConfiguredRemove(RepositoryList list) {
- for (Iterator iter = list.getRepositoryList().iterator(); iter.hasNext();) {
- DestinationRepository repo = (DestinationRepository) iter.next();
+ for (DestinationRepository repo : list.getRepositoryList()) {
((CompositeRepositoryApplication) application).removeChild(repo.getDescriptor());
}
}
@@ -66,4 +69,35 @@ public class CompositeRepositoryTask extends AbstractRepositoryTask {
public void setValidate(String value) {
((CompositeRepositoryApplication) application).setComparator(value);
}
+
+ /* p2.composite.artifact.repository.add
+ * p2.composite.artifact.repository.remove*/
+ public void setLocation(String value) {
+ super.setDestination(value);
+ }
+
+ /* p2.composite.artifact.repository.add
+ * p2.composite.artifact.repository.remove*/
+ public void setChild(String value) throws URISyntaxException {
+ URI childURI = URIUtil.fromString(value);
+ RepositoryDescriptor repo = new RepositoryDescriptor();
+ repo.setLocation(childURI);
+
+ if (getTaskName().equals(COMPOSITE_ADD))
+ ((CompositeRepositoryApplication) application).addChild(repo);
+ else if (getTaskName().equals(COMPOSITE_REMOVE))
+ ((CompositeRepositoryApplication) application).removeChild(repo);
+ }
+
+ /* p2.composite.artifact.repository.add */
+ public void setComparatorID(String value) {
+ if (value != null && !value.startsWith(ANT_PREFIX))
+ ((CompositeRepositoryApplication) application).setComparator(value);
+ }
+
+ /* p2.composite.artifact.repository.remove */
+ public void setAllChildren(String value) {
+ if (value != null && !value.startsWith(ANT_PREFIX))
+ ((CompositeRepositoryApplication) application).setRemoveAll(Boolean.valueOf(value).booleanValue());
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeArtifactRepositoryTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeArtifactRepositoryTask.java
new file mode 100644
index 000000000..d2a4a481a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeArtifactRepositoryTask.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 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 java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
+import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+
+/**
+ * Ant task for creating a new composite artifact repository.
+ */
+public class CreateCompositeArtifactRepositoryTask extends Task {
+
+ URI location; // desired location of the composite repository
+ String name = "Composite Artifact Repository";
+ boolean compressed = true;
+ boolean failOnExists = false; // should we fail if a repo already exists?
+ Map<String, String> properties = new HashMap<String, String>();
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() {
+ validate();
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ if (manager == null)
+ throw new BuildException("Unable to aquire artifact repository manager service.");
+
+ // remove the repo first.
+ manager.removeRepository(location);
+
+ // first try and load to see if one already exists at that location.
+ // if we have an already existing repository at that location, then throw an error
+ // if the user told us to
+ try {
+ IArtifactRepository repository = manager.loadRepository(location, null);
+ if (repository instanceof CompositeArtifactRepository) {
+ if (failOnExists)
+ throw new BuildException("Composite repository already exists at location: " + location);
+ return;
+ } else {
+ // we have a non-composite repo at this location. that is ok because we can co-exist.
+ }
+ } catch (ProvisionException e) {
+ // re-throw the exception if we got anything other than "repo not found"
+ if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND)
+ throw new BuildException("Exception while trying to read repository at: " + location, e);
+ }
+
+ // set the properties
+ if (compressed)
+ properties.put(IRepository.PROP_COMPRESSED, Boolean.toString(true));
+
+ // create the repository
+ try {
+ manager.createRepository(location, name, IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, properties);
+ } catch (ProvisionException e) {
+ throw new BuildException("Error occurred while creating composite artifact repository.", e);
+ }
+ }
+
+ /*
+ * Perform basic sanity checking of some of the parameters.
+ */
+ private void validate() {
+ if (location == null)
+ throw new BuildException("Must specify repository location.");
+ if (name == null)
+ throw new BuildException("Must specify a repository name.");
+ }
+
+ /*
+ * Set the name of the composite repository.
+ */
+ public void setName(String value) {
+ name = value;
+ }
+
+ /*
+ * Set the location of the repository.
+ */
+ public void setLocation(String value) throws URISyntaxException {
+ location = URIUtil.fromString(value);
+ }
+
+ /*
+ * Set a value indicating whether or not the repository should be compressed.
+ */
+ public void setCompressed(boolean value) {
+ compressed = value;
+ }
+
+ /*
+ * Set whether or not we should fail the operation if a repository
+ * already exists at the location.
+ */
+ public void setFailOnExists(boolean value) {
+ failOnExists = value;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/IUDescription.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/IUDescription.java
index 70a91b01c..f02a2b74a 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/IUDescription.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/IUDescription.java
@@ -10,11 +10,18 @@
*******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+import org.eclipse.equinox.p2.metadata.Version;
+
import java.util.*;
import org.apache.tools.ant.types.DataType;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
+import org.eclipse.equinox.internal.p2.metadata.query.IUPropertyQuery;
+import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery;
import org.eclipse.equinox.p2.internal.repository.tools.Activator;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.PipedQuery;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
@@ -100,29 +107,32 @@ public class IUDescription extends DataType {
return buffer.toString();
}
- public Query createQuery() {
- List queries = new ArrayList();
+ public IQuery<IInstallableUnit> createQuery() {
+ List<IQuery<IInstallableUnit>> queries = new ArrayList<IQuery<IInstallableUnit>>();
if (id != null) {
if (version == null || version.length() == 0) {
// Get the latest version of the iu
queries.add(new InstallableUnitQuery(id));
- queries.add(new LatestIUVersionQuery());
+ queries.add(new LatestIUVersionQuery<IInstallableUnit>());
} else {
Version iuVersion = Version.parseVersion(version);
queries.add(new InstallableUnitQuery(id, iuVersion));
}
}
- Query iuQuery = processQueryString();
+ IQuery<IInstallableUnit> iuQuery = processQueryString();
if (iuQuery != null)
queries.add(iuQuery);
if (queries.size() == 1)
- return (Query) queries.get(0);
- return new CompositeQuery((Query[]) queries.toArray(new Query[queries.size()]));
+ return queries.get(0);
+
+ @SuppressWarnings("unchecked")
+ IQuery<IInstallableUnit> query = new PipedQuery<IInstallableUnit>(queries.toArray(new IQuery[queries.size()]));
+ return query;
}
- private Query processQueryString() {
+ private IQuery<IInstallableUnit> processQueryString() {
if (queryString == null)
return null;
int startIdx = queryString.indexOf('[');
@@ -130,10 +140,10 @@ public class IUDescription extends DataType {
if (startIdx == -1 || endIdx == -1 || endIdx < startIdx)
return null;
String element = queryString.substring(0, startIdx);
- Map attributes = processQueryAttributes(queryString.substring(startIdx + 1, endIdx));
+ Map<String, String> attributes = processQueryAttributes(queryString.substring(startIdx + 1, endIdx));
if (element.equals(QUERY_PROPERTY)) {
- String name = (String) attributes.get(QUERY_NAME);
- String value = (String) attributes.get(QUERY_VALUE);
+ String name = attributes.get(QUERY_NAME);
+ String value = attributes.get(QUERY_VALUE);
if (name == null)
return null;
return new IUPropertyQuery(name, value);
@@ -142,11 +152,11 @@ public class IUDescription extends DataType {
return null;
}
- private Map processQueryAttributes(String attributes) {
+ private Map<String, String> processQueryAttributes(String attributes) {
if (attributes == null || attributes.length() == 0)
- return Collections.EMPTY_MAP;
+ return CollectionUtils.emptyMap();
- Map result = new HashMap();
+ Map<String, String> result = new HashMap<String, String>();
int start = 0;
int idx = 0;
while ((idx = attributes.indexOf('@', start)) > -1) {
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorArtifactsTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorArtifactsTask.java
new file mode 100644
index 000000000..f75497bf4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorArtifactsTask.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 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.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication;
+import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
+
+/**
+ * Ant task for running the artifact repository mirroring application.
+ */
+public class MirrorArtifactsTask extends Task {
+ URI source;
+ URI destination;
+ String destinationName;
+ URI baseline; // location of known good repository for compare against (optional)
+ File mirrorLog; // file to log mirror output to (optional)
+ File comparatorLog; // file to comparator output to (optional)
+ String comparatorID; // specifies a comparator (optional)
+ String writeMode;
+ boolean compare = false;
+ boolean ignoreErrors = false;
+ boolean raw = false; // use raw artifact descriptors?
+ boolean verbose = false;
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() {
+ // Compare against if baseline specified
+ RepositoryDescriptor destinationRepo = new RepositoryDescriptor();
+ destinationRepo.setName(destinationName);
+ destinationRepo.setLocation(destination);
+ destinationRepo.setKind(RepositoryDescriptor.KIND_ARTIFACT);
+ if (writeMode != null && writeMode.equals("clean")) //$NON-NLS-1$
+ destinationRepo.setAppend(false);
+
+ RepositoryDescriptor sourceRepo = new RepositoryDescriptor();
+ sourceRepo.setLocation(source);
+ sourceRepo.setKind(RepositoryDescriptor.KIND_ARTIFACT);
+
+ MirrorApplication app = new MirrorApplication();
+ app.addDestination(destinationRepo);
+ app.addSource(sourceRepo);
+ app.setRaw(raw);
+ app.setIgnoreErrors(ignoreErrors);
+ app.setVerbose(verbose);
+ app.setCompare(compare);
+ app.setComparatorID(comparatorID);
+ app.setBaseline(baseline);
+ if (comparatorLog != null)
+ app.setComparatorLog(comparatorLog);
+ if (mirrorLog != null)
+ app.setLog(mirrorLog);
+ else {
+ try {
+ app.setLog(new AntMirrorLog(this));
+ } catch (NoSuchMethodException e) {
+ //shouldn't happen
+ }
+ }
+
+ try {
+ app.run(null);
+ } catch (Exception e) {
+ throw new BuildException("Exception while running mirror application.", e);
+ }
+ }
+
+ /*
+ * Set the location of the source.
+ */
+ public void setSource(String value) {
+ try {
+ source = URIUtil.fromString(value);
+ } catch (URISyntaxException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /*
+ * Set the location of the destination.
+ */
+ public void setDestination(String value) {
+ try {
+ destination = URIUtil.fromString(value);
+ } catch (URISyntaxException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /*
+ * Set the name of the destination repository.
+ */
+ public void setDestinationName(String value) {
+ destinationName = value;
+ }
+
+ /*
+ * Set the location of the baseline repository. (used in comparison)
+ */
+ public void setBaseline(String value) {
+ try {
+ baseline = URIUtil.fromString(value);
+ } catch (URISyntaxException e) {
+ throw new BuildException(e);
+ }
+ compare = true;
+ }
+
+ /*
+ * Set the identifier of the comparator to use.
+ */
+ public void setComparatorID(String value) {
+ comparatorID = value;
+ compare = true;
+ }
+
+ /*
+ * Set the location of the comparator log
+ */
+ public void setComparatorLog(String value) {
+ comparatorLog = new File(value);
+ }
+
+ /*
+ * Set the write mode. (e.g. clean or append)
+ */
+ public void setWriteMode(String value) {
+ writeMode = value;
+ }
+
+ /*
+ * Set the log location if applicable
+ */
+ public void setLog(String value) {
+ mirrorLog = new File(value);
+ }
+
+ /*
+ * Set whether or not the application should be calling a comparator when mirroring.
+ */
+ public void setCompare(boolean value) {
+ compare = value;
+ }
+
+ /*
+ * Set whether or not we should ignore errors when running the mirror application.
+ */
+ public void setIgnoreErrors(boolean value) {
+ ignoreErrors = value;
+ }
+
+ /*
+ * Set whether or not the the artifacts are raw.
+ */
+ public void setRaw(boolean value) {
+ raw = value;
+ }
+
+ /*
+ * Set whether or not the mirror application should be run in verbose mode.
+ */
+ public void setVerbose(boolean value) {
+ verbose = value;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorMetadataTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorMetadataTask.java
new file mode 100644
index 000000000..f4350f3da
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorMetadataTask.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 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 java.net.URI;
+import java.net.URISyntaxException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.URIUtil;
+import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication;
+import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
+
+/**
+ * Ant task for running the metadata mirror application.
+ */
+public class MirrorMetadataTask extends Task {
+ URI source;
+ URI destination;
+ String destinationName;
+ String writeMode;
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() {
+ RepositoryDescriptor destinationRepo = new RepositoryDescriptor();
+ destinationRepo.setName(destinationName);
+ destinationRepo.setLocation(destination);
+ destinationRepo.setKind(RepositoryDescriptor.KIND_METADATA);
+ if (writeMode != null && writeMode.equals("clean")) //$NON-NLS-1$
+ destinationRepo.setAppend(false);
+
+ RepositoryDescriptor sourceRepo = new RepositoryDescriptor();
+ sourceRepo.setLocation(source);
+ sourceRepo.setKind(RepositoryDescriptor.KIND_METADATA);
+
+ MirrorApplication app = new MirrorApplication();
+ app.addDestination(destinationRepo);
+ app.addSource(sourceRepo);
+ try {
+ IStatus result = app.run(null);
+ if (result.getSeverity() != IStatus.OK)
+ log(result.getMessage());
+ } catch (ProvisionException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /*
+ * Set the source location.
+ */
+ public void setSource(String value) {
+ try {
+ source = URIUtil.fromString(value);
+ } catch (URISyntaxException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /*
+ * Set the destination location.
+ */
+ public void setDestination(String value) {
+ try {
+ destination = URIUtil.fromString(value);
+ } catch (URISyntaxException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /*
+ * Set the destination name.
+ */
+ public void setDestinationName(String value) {
+ destinationName = value;
+ }
+
+ /*
+ * Set the write mode for the application. (e.g. clean or append)
+ */
+ public void setWriteMode(String value) {
+ writeMode = value;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java
index fceaaf32a..71f2b8bda 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java
@@ -10,14 +10,15 @@
*******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+import org.eclipse.equinox.p2.core.ProvisionException;
+
import java.io.File;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.p2.artifact.repository.ant.AntMirrorLog;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.p2.internal.repository.tools.Messages;
import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
public class MirrorTask extends AbstractRepositoryTask {
@@ -51,7 +52,7 @@ public class MirrorTask extends AbstractRepositoryTask {
prepareSourceRepos();
application.initializeRepos(null);
- List ius = prepareIUs();
+ List<IInstallableUnit> ius = prepareIUs();
application.setSourceIUs(ius);
IStatus result = application.run(null);
if (result.matches(IStatus.ERROR))
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
index 9e8947335..aa069e184 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java
@@ -12,7 +12,6 @@
package org.eclipse.equinox.p2.internal.repository.tools.tasks;
import java.io.File;
-import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.tools.ant.BuildException;
@@ -20,7 +19,7 @@ import org.apache.tools.ant.Task;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.jarprocessor.ant.JarProcessorTask;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.internal.repository.tools.*;
import org.eclipse.osgi.util.NLS;
@@ -64,7 +63,8 @@ public class ProcessRepoTask extends Task {
public void execute() throws BuildException {
File file = URIUtil.toFile(repository);
if (file == null || !file.exists()) {
- throw new BuildException(NLS.bind(Messages.ProcessRepo_must_be_local, repository.toString()));
+ throw new BuildException(NLS.bind(
+ Messages.ProcessRepo_must_be_local, repository.toString()));
}
if (pack | repack | signing != null) {
if (jarProcessor == null)
@@ -76,7 +76,8 @@ public class ProcessRepoTask extends Task {
jarProcessor.setStorepass(signing.storepass);
jarProcessor.setUnsign(signing.unsign);
- if (signing.alias != null && signing.alias.length() > 0 && !signing.alias.startsWith("${")) //$NON-NLS-1$
+ if (signing.alias != null && signing.alias.length() > 0
+ && !signing.alias.startsWith("${")) //$NON-NLS-1$
jarProcessor.setSign(true);
}
jarProcessor.setPack(pack);
@@ -103,9 +104,6 @@ public class ProcessRepoTask extends Task {
} catch (ProvisionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
}
@@ -113,7 +111,8 @@ public class ProcessRepoTask extends Task {
try {
this.repository = URIUtil.fromString(repository);
} catch (URISyntaxException e) {
- throw new IllegalArgumentException(NLS.bind(Messages.ProcessRepo_location_not_url, repository));
+ throw new IllegalArgumentException(NLS.bind(
+ Messages.ProcessRepo_location_not_url, repository));
}
}
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
index c766504b8..531134c24 100644
--- 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
@@ -14,15 +14,16 @@ import java.util.*;
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.IArtifactDescriptor;
-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.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.internal.repository.tools.AbstractApplication;
import org.eclipse.equinox.p2.internal.repository.tools.Messages;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
@@ -59,20 +60,18 @@ public class RemoveIUTask extends AbstractRepositoryTask {
IMetadataRepository repository = application.getDestinationMetadataRepository();
IArtifactRepository artifacts = application.getDestinationArtifactRepository();
- final Set toRemove = new HashSet();
- for (Iterator iter = iuTasks.iterator(); iter.hasNext();) {
- IUDescription iu = (IUDescription) iter.next();
- Query iuQuery = iu.createQuery();
+ final Set<IInstallableUnit> toRemove = new HashSet<IInstallableUnit>();
+ for (IUDescription iu : iuTasks) {
+ IQuery<IInstallableUnit> iuQuery = iu.createQuery();
- Collector collector = new Collector();
- repository.query(iuQuery, collector, null);
+ IQueryResult<IInstallableUnit> queryResult = repository.query(iuQuery, null);
- if (collector.isEmpty())
+ if (queryResult.isEmpty())
getProject().log(NLS.bind(Messages.AbstractRepositoryTask_unableToFind, iu.toString()));
else {
- for (Iterator iterator = collector.iterator(); iterator.hasNext();) {
- IInstallableUnit unit = (IInstallableUnit) iterator.next();
- IArtifactKey[] keys = unit.getArtifacts();
+ for (Iterator<IInstallableUnit> iterator = queryResult.iterator(); iterator.hasNext();) {
+ IInstallableUnit unit = iterator.next();
+ Collection<IArtifactKey> keys = unit.getArtifacts();
Filter filter = null;
try {
filter = iu.getArtifactFilter();
@@ -83,11 +82,11 @@ public class RemoveIUTask extends AbstractRepositoryTask {
//we will only remove the metadata if all artifacts were removed
boolean removeMetadata = true;
- for (int i = 0; i < keys.length; i++) {
+ for (IArtifactKey key : keys) {
if (filter == null) {
- artifacts.removeDescriptor(keys[i]);
+ artifacts.removeDescriptor(key);
} else {
- IArtifactDescriptor[] descriptors = artifacts.getArtifactDescriptors(keys[i]);
+ IArtifactDescriptor[] descriptors = artifacts.getArtifactDescriptors(key);
for (int j = 0; j < descriptors.length; j++) {
if (filter.match(createDictionary(descriptors[j]))) {
artifacts.removeDescriptor(descriptors[j]);
@@ -104,12 +103,7 @@ public class RemoveIUTask extends AbstractRepositoryTask {
}
if (toRemove.size() > 0) {
- Query removeQuery = new MatchQuery() {
- public boolean isMatch(Object candidate) {
- return toRemove.contains(candidate);
- }
- };
- repository.removeInstallableUnits(removeQuery, null);
+ repository.removeInstallableUnits(toRemove.toArray(new IInstallableUnit[toRemove.size()]), null);
}
} catch (ProvisionException e) {
throw new BuildException(e);
@@ -122,8 +116,8 @@ public class RemoveIUTask extends AbstractRepositoryTask {
}
}
- private Dictionary createDictionary(IArtifactDescriptor descriptor) {
- Hashtable result = new Hashtable(5);
+ private Dictionary<String, Object> createDictionary(IArtifactDescriptor descriptor) {
+ Hashtable<String, Object> result = new Hashtable<String, Object>(5);
result.putAll(descriptor.getProperties());
IArtifactKey key = descriptor.getArtifactKey();
result.put(CLASSIFIER, key.getClassifier());
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
index 8763492a5..f0af711ae 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/Repo2RunnableTask.java
@@ -10,13 +10,16 @@
*******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools.tasks;
+import org.eclipse.equinox.p2.core.ProvisionException;
+
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.p2.internal.repository.tools.Messages;
import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.osgi.util.NLS;
/**
* Ant task which calls the "repo to runnable" application. This application takes an
@@ -47,7 +50,7 @@ public class Repo2RunnableTask extends AbstractRepositoryTask {
try {
prepareSourceRepos();
application.initializeRepos(null);
- List ius = prepareIUs();
+ List<IInstallableUnit> ius = prepareIUs();
if ((ius == null || ius.size() == 0) && !(application.hasArtifactSources() || application.hasMetadataSources()))
throw new BuildException(Messages.exception_needIUsOrNonEmptyRepo);
application.setSourceIUs(ius);
@@ -56,9 +59,9 @@ public class Repo2RunnableTask extends AbstractRepositoryTask {
throw new ProvisionException(result);
} catch (ProvisionException e) {
if (failOnError)
- throw new BuildException(Messages.Repo2RunnableTask_errorTransforming, e);
+ throw new BuildException(NLS.bind(Messages.Repo2RunnableTask_errorTransforming, null != e.getMessage() ? e.getMessage() : e.toString()), e);
/* else */
- getProject().log(Messages.Repo2RunnableTask_errorTransforming, Project.MSG_WARN);
+ getProject().log(NLS.bind(Messages.Repo2RunnableTask_errorTransforming, null != e.getMessage() ? e.getMessage() : e.toString()), Project.MSG_WARN);
getProject().log(e.getMessage(), Project.MSG_WARN);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java
index c7e88ddf4..79b16675c 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java
@@ -16,8 +16,8 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.FileSet;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
+import org.eclipse.equinox.p2.repository.IRepository;
public class RepositoryFileSet extends FileSet {
public final static int TYPE_ARTIFACT = IRepository.TYPE_ARTIFACT;
@@ -47,17 +47,14 @@ public class RepositoryFileSet extends FileSet {
}
public void setLocation(String value) {
- // TODO depreciate
myLocation = value;
}
public String getRepoLocation() {
- // TODO depreciate
return myLocation;
}
public URI getRepoLocationURI() {
- // TODO depreciate
try {
return RepositoryHelper.localRepoURIHelper(URIUtil.fromString(getRepoLocation()));
} catch (URISyntaxException e) {
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java
index a76d3218d..8f31ce3a7 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java
@@ -12,11 +12,12 @@ package org.eclipse.equinox.p2.internal.repository.tools.tasks;
import java.util.ArrayList;
import java.util.List;
+import org.apache.tools.ant.types.FileSet;
public class RepositoryList extends RepositoryFileSet {
// TODO this class should extend DataType, currently RepoFileSet to support <source location="xxx" />
- List repositories = new ArrayList();
- List sourceFileSets = new ArrayList();
+ List<DestinationRepository> repositories = new ArrayList<DestinationRepository>();
+ List<FileSet> sourceFileSets = new ArrayList<FileSet>();
public DestinationRepository createRepository() {
DestinationRepository repo = new DestinationRepository();
@@ -30,11 +31,11 @@ public class RepositoryList extends RepositoryFileSet {
return fileSet;
}
- public List getRepositoryList() {
+ public List<DestinationRepository> getRepositoryList() {
return repositories;
}
- public List getFileSetList() {
+ public List<FileSet> getFileSetList() {
//TODO this should eventually be removed
sourceFileSets.add(this);
return sourceFileSets;
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java
index fcd8a6b37..774201a83 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java
@@ -56,7 +56,7 @@ public class SlicingOption extends Task {
StringTokenizer tok = new StringTokenizer(platformFilter, ","); //$NON-NLS-1$
if (tok.countTokens() != 3)
throw new BuildException(NLS.bind(Messages.SlicingOption_invalid_platform, platformFilter));
- Dictionary filter = options.getFilter();
+ Dictionary<String, Object> filter = options.getFilter();
filter.put("osgi.os", tok.nextToken().trim()); //$NON-NLS-1$
filter.put("osgi.ws", tok.nextToken().trim()); //$NON-NLS-1$
filter.put("osgi.arch", tok.nextToken().trim()); //$NON-NLS-1$
@@ -68,7 +68,7 @@ public class SlicingOption extends Task {
}
public void setIncludeFeatures(boolean includeFeatures) {
- Dictionary filter = options.getFilter();
+ Dictionary<String, Object> filter = options.getFilter();
filter.put("org.eclipse.update.install.features", String.valueOf(includeFeatures)); //$NON-NLS-1$
options.setFilter(filter);
}
@@ -76,7 +76,7 @@ public class SlicingOption extends Task {
public void setFilter(String filterString) {
if (filterString == null || filterString.trim().equals("")) //$NON-NLS-1$
return;
- Dictionary filter = options.getFilter();
+ Dictionary<String, Object> filter = options.getFilter();
StringTokenizer tok = new StringTokenizer(filterString, ","); //$NON-NLS-1$
while (tok.hasMoreTokens()) {
String rule = tok.nextToken().trim();
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ValidateTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ValidateTask.java
new file mode 100644
index 000000000..5b3188218
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ValidateTask.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 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.net.URI;
+import org.apache.tools.ant.BuildException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.internal.repository.tools.ArtifactRepositoryValidator;
+import org.eclipse.equinox.p2.internal.repository.tools.Messages;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+
+/**
+ * Ant task for validating the contents of a composite artifact repository.
+ */
+public class ValidateTask extends AbstractRepositoryTask {
+
+ private String comparatorID; // specifies the comparator we want to use.
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() {
+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ if (manager == null)
+ throw new BuildException(Messages.no_artifactRepo_manager);
+
+ ArtifactRepositoryValidator validator;
+ try {
+ validator = new ArtifactRepositoryValidator(comparatorID);
+ } catch (ProvisionException e) {
+ throw new BuildException(Messages.invalidComparatorId, e);
+ }
+
+ IArtifactRepository artifactRepository = null;
+ for (DestinationRepository repo : destinations) {
+ URI repoLocation = repo.getDescriptor().getRepoLocation();
+ try {
+ artifactRepository = manager.loadRepository(repoLocation, null);
+ IStatus result = validator.validateRepository(artifactRepository);
+ if (!result.isOK())
+ throw new BuildException(result.getMessage());
+ } catch (ProvisionException e) {
+ throw new BuildException(Messages.exception_loadingRepository, e);
+ }
+ }
+ }
+
+ /*
+ * Set the repository location.
+ */
+ public void setLocation(String value) {
+ super.setDestination(value);
+ }
+
+ /*
+ * Set the ID of the comparator.
+ */
+ public void setComparatorID(String value) {
+ comparatorID = value;
+ }
+}

Back to the top