Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java82
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AntMirrorLog.java105
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java120
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java221
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java76
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java68
6 files changed, 0 insertions, 672 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java
deleted file mode 100644
index a2e122805..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * 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.internal.p2.artifact.repository.ant;
-
-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.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.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-
-/**
- * Ant task to add a child artifact repository to an already-existing composite artifact repository.
- */
-public class AddChildTask extends Task {
-
- URI location; // location of the composite repository
- URI child; // address of the child to add
- String comparatorID; // comparator to use for compare (optional)
-
- /* (non-Javadoc)
- * @see org.apache.tools.ant.Task#execute()
- */
- public void execute() {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- if (manager == null)
- throw new BuildException("Unable to acquire artifact repository manager service.");
-
- // get the composite repository
- CompositeArtifactRepository repo = null;
- try {
- repo = (CompositeArtifactRepository) manager.loadRepository(location, null);
- } catch (ProvisionException e) {
- throw new BuildException("Exception while loading repository.", e);
- }
-
- // just do a straight add if the user didn't specify a comparator.
- if (comparatorID == null) {
- repo.addChild(child);
- return;
- }
-
- // otherwise run the comparator when we try and add the child and print out the result.
- if (repo.addChild(child, comparatorID))
- System.out.println(child + " was added successfully.");
- else
- System.out.println(child + " was not added.");
- }
-
- /*
- * Set the location of the composite repository.
- */
- public void setLocation(String value) throws URISyntaxException {
- location = URIUtil.fromString(value);
- }
-
- /*
- * Set the location of the child repository.
- */
- public void setChild(String value) throws URISyntaxException {
- child = URIUtil.fromString(value);
- }
-
- /*
- * Set the identifier of the comparator to use.
- */
- public void setComparatorID(String value) {
- comparatorID = value;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AntMirrorLog.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AntMirrorLog.java
deleted file mode 100644
index 9d30c11f0..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AntMirrorLog.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * 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.internal.p2.artifact.repository.ant;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.p2.artifact.mirror.IArtifactMirrorLog;
-import org.eclipse.equinox.internal.p2.artifact.repository.Messages;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.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.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java
deleted file mode 100644
index a86224e53..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * 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.internal.p2.artifact.repository.ant;
-
-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.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-
-/**
- * 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 properties = new HashMap();
-
- /* (non-Javadoc)
- * @see org.apache.tools.ant.Task#execute()
- */
- public void execute() {
- validate();
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- 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.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java
deleted file mode 100644
index 5040961cf..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * 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.internal.p2.artifact.repository.ant;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.eclipse.equinox.app.IApplicationContext;
-import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication;
-import org.osgi.framework.Bundle;
-
-/**
- * Ant task for running the artifact repository mirroring application.
- */
-public class MirrorApplicationTask extends Task {
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static final String ARG_COMPARATOR = "-comparator"; //$NON-NLS-1$
- private static final String ARG_COMPARE = "-compare"; //$NON-NLS-1$
- private static final String ARG_COMPARE_AGAINST = "-compareAgainst"; //$NON-NLS-1$
- private static final String ARG_COMPARATOR_LOG = "-comparatorLog"; //$NON-NLS-1$
- private static final String ARG_DESTINATION = "-destination"; //$NON-NLS-1$
- private static final String ARG_DESTINATION_NAME = "-destinationName"; //$NON-NLS-1$
- private static final String ARG_IGNORE_ERRORS = "-ignoreErrors"; //$NON-NLS-1$
- private static final String ARG_LOG = "-log"; //$NON-NLS-1$
- private static final String ARG_RAW = "-raw"; //$NON-NLS-1$
- private static final String ARG_SOURCE = "-source"; //$NON-NLS-1$
- private static final String ARG_VERBOSE = "-verbose"; //$NON-NLS-1$
- private static final String ARG_WRITE_MODE = "-writeMode"; //$NON-NLS-1$
-
- URL source;
- URL destination;
- String destinationName;
- URL 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;
-
- /*
- * Runs the mirror application with the given arguments.
- */
- private void runMirrorApplication(final String[] args) throws Exception {
- MirrorApplication app = new MirrorApplication();
- if (mirrorLog == null)
- app.setLog(new AntMirrorLog(this));
- app.start(new IApplicationContext() {
-
- public void applicationRunning() {
- // nothing to do
- }
-
- public Map getArguments() {
- Map arguments = new HashMap();
- arguments.put(IApplicationContext.APPLICATION_ARGS, args);
- return arguments;
- }
-
- public String getBrandingApplication() {
- return null;
- }
-
- public Bundle getBrandingBundle() {
- return null;
- }
-
- public String getBrandingDescription() {
- return null;
- }
-
- public String getBrandingId() {
- return null;
- }
-
- public String getBrandingName() {
- return null;
- }
-
- public String getBrandingProperty(String key) {
- return null;
- }
- });
- }
-
- /* (non-Javadoc)
- * @see org.apache.tools.ant.Task#execute()
- */
- public void execute() {
- // Compare against if baseline specified
- boolean compareAgainst = baseline != null;
- boolean comparator = comparatorID != null;
-
- // create arguments
- String[] args = new String[] { //
- ARG_SOURCE, source.toExternalForm(), //
- ARG_DESTINATION, destination.toExternalForm(), //
- ARG_WRITE_MODE, writeMode == null ? EMPTY_STRING : writeMode, //
- compare ? ARG_COMPARE : EMPTY_STRING, //
- ignoreErrors ? ARG_IGNORE_ERRORS : EMPTY_STRING, //
- raw ? ARG_RAW : EMPTY_STRING, //
- verbose ? ARG_VERBOSE : EMPTY_STRING, //
- compareAgainst ? ARG_COMPARE_AGAINST : EMPTY_STRING, //
- compareAgainst ? baseline.toExternalForm() : EMPTY_STRING, //
- comparator ? ARG_COMPARATOR : EMPTY_STRING, //
- comparator ? comparatorID : EMPTY_STRING, //
- mirrorLog != null ? ARG_LOG : EMPTY_STRING, //
- mirrorLog != null ? mirrorLog.getAbsolutePath() : EMPTY_STRING, //
- comparatorLog != null ? ARG_COMPARATOR_LOG : EMPTY_STRING, //
- comparatorLog != null ? comparatorLog.getAbsolutePath() : EMPTY_STRING, //
- destinationName != null ? ARG_DESTINATION_NAME : EMPTY_STRING, //
- destinationName != null ? destinationName : EMPTY_STRING};
-
- try {
- runMirrorApplication(args);
- } catch (Exception e) {
- throw new BuildException("Exception while running mirror application.", e);
- }
- }
-
- /*
- * Set the location of the source.
- */
- public void setSource(String value) throws MalformedURLException {
- source = new URL(value);
- }
-
- /*
- * Set the location of the destination.
- */
- public void setDestination(String value) throws MalformedURLException {
- destination = new URL(value);
- }
-
- /*
- * 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) throws MalformedURLException {
- baseline = new URL(value);
- 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.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java
deleted file mode 100644
index 2a1212660..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * 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.internal.p2.artifact.repository.ant;
-
-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.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.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-
-/**
- * Ant task for removing a specific child from a composite artifact repository.
- */
-public class RemoveChildTask extends Task {
-
- URI location; // location of the composite repository
- URI child; // location of child to remove
- boolean allChildren = false; // should we remove all children?
-
- /* (non-Javadoc)
- * @see org.apache.tools.ant.Task#execute()
- */
- public void execute() {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- if (manager == null)
- throw new BuildException("Unable to aquire artifact repository manager service.");
-
- // load repository
- CompositeArtifactRepository repo;
- try {
- repo = (CompositeArtifactRepository) manager.loadRepository(location, null);
- } catch (ProvisionException e) {
- throw new BuildException("Error occurred while loading repository.", e);
- }
-
- // remove all children or just a specified child
- if (allChildren)
- repo.removeAllChildren();
- else
- repo.removeChild(child);
- }
-
- /*
- * Set the repository location.
- */
- public void setLocation(String value) throws URISyntaxException {
- location = URIUtil.fromString(value);
- }
-
- /*
- * Set the child repository location.
- */
- public void setChild(String value) throws URISyntaxException {
- child = URIUtil.fromString(value);
- }
-
- /*
- * Set whether or not we want to remove all the children.
- */
- public void setAllChildren(String value) {
- allChildren = Boolean.valueOf(value).booleanValue();
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java
deleted file mode 100644
index 96a4d3a7e..000000000
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * 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.internal.p2.artifact.repository.ant;
-
-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.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.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-
-/**
- * Ant task for validating the contents of a composite artifact repository.
- */
-public class ValidateTask extends Task {
-
- URI location; // location of the composite repository
- 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.class.getName());
- if (manager == null)
- throw new BuildException("Unable to aquire artifact repository manager service.");
-
- // load the repository
- CompositeArtifactRepository repo = null;
- try {
- repo = (CompositeArtifactRepository) manager.loadRepository(location, null);
- } catch (ProvisionException e) {
- throw new BuildException("Exception while loading repository.", e);
- }
-
- // perform the sanity check
- if (repo.validate(comparatorID))
- System.err.println("Valid repository at: " + location);
- else
- System.err.println("Invalid repository at: " + location);
- }
-
- /*
- * Set the repository location.
- */
- public void setLocation(String value) throws URISyntaxException {
- location = URIUtil.fromString(value);
- }
-
- /*
- * Set the ID of the comparator.
- */
- public void setComparatorID(String value) {
- comparatorID = value;
- }
-}

Back to the top