Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2009-01-13 23:27:00 +0000
committerDJ Houghton2009-01-13 23:27:00 +0000
commite8f60341d765f5de84d7b804679b3b1a866b90c4 (patch)
tree5b31f7a31e576d6623e78ad12108424b55792ef9
parent2bfd26c3f5ae3cc9aeb9b7e404de1ebadac5224b (diff)
downloadrt.equinox.p2-e8f60341d765f5de84d7b804679b3b1a866b90c4.tar.gz
rt.equinox.p2-e8f60341d765f5de84d7b804679b3b1a866b90c4.tar.xz
rt.equinox.p2-e8f60341d765f5de84d7b804679b3b1a866b90c4.zip
Bug 255913 - [mirror] Need ant tasks for mirroring applications
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.classpath1
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.externalToolBuilders/org.eclipse.equinox.p2.artifact.repository buildAntTasks.xml.launch18
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/.project10
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/build.properties10
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/buildAntTasks.xml9
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml41
-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/CreateCompositeArtifactRepositoryTask.java91
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java184
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveAllChildrenTask.java56
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java65
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/.classpath1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch18
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/.project10
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/build.properties10
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/buildAntTasks.xml9
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml34
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java79
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java80
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java117
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java56
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java62
23 files changed, 1107 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/.classpath b/bundles/org.eclipse.equinox.p2.artifact.repository/.classpath
index 2fbb7a23e..ef379494d 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/.classpath
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.classpath
@@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" output="bin_ant" path="src_ant"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/.externalToolBuilders/org.eclipse.equinox.p2.artifact.repository buildAntTasks.xml.launch b/bundles/org.eclipse.equinox.p2.artifact.repository/.externalToolBuilders/org.eclipse.equinox.p2.artifact.repository buildAntTasks.xml.launch
new file mode 100644
index 000000000..c2ad0a0ec
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.externalToolBuilders/org.eclipse.equinox.p2.artifact.repository buildAntTasks.xml.launch
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.equinox.p2.artifact.repository/buildAntTasks.xml"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.equinox.p2.artifact.repository"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.equinox.p2.artifact.repository/buildAntTasks.xml}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/.project b/bundles/org.eclipse.equinox.p2.artifact.repository/.project
index e03096bd7..c6af226d8 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/.project
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/.project
@@ -20,6 +20,16 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>LaunchConfigHandle</key>
+ <value>&lt;project&gt;/.externalToolBuilders/org.eclipse.equinox.p2.artifact.repository buildAntTasks.xml.launch</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties b/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties
index 1e585bda9..f00d7fb2b 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007 IBM Corporation and others.
+# Copyright (c) 2007, 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
@@ -14,6 +14,12 @@ bin.includes = META-INF/,\
.,\
plugin.xml,\
about.html,\
- plugin.properties
+ plugin.properties,\
+ ant_tasks/artifactRepository-ant.jar
src.includes = about.html,\
schema/
+jars.extra.classpath = platform:/plugin/org.apache.ant/lib/ant.jar
+jars.compile.order = .,\
+ ant_tasks/artifactRepository-ant.jar
+source.ant_tasks/artifactRepository-ant.jar = src_ant/
+output.ant_tasks/artifactRepository-ant.jar = bin_ant/
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/buildAntTasks.xml b/bundles/org.eclipse.equinox.p2.artifact.repository/buildAntTasks.xml
new file mode 100644
index 000000000..f312fda9f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/buildAntTasks.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.equinox.p2.metadata.generator" default="default" basedir=".">
+
+ <target name="default" description="Jar up the binaries that were compiled by the jdt builder" >
+ <mkdir dir="${basedir}/ant_tasks" />
+ <delete file="${basedir}/ant_tasks/artifactRepository-ant.jar" failonerror="false"/>
+ <jar destfile="${basedir}/ant_tasks/artifactRepository-ant.jar" basedir="${basedir}/bin_ant"/>
+ </target>
+</project> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml b/bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml
index c50d9c94a..a67a8d5dd 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml
@@ -43,4 +43,45 @@
<artifactComparator class="org.eclipse.equinox.internal.p2.artifact.processors.md5.MD5ArtifactComparator"
id="org.eclipse.equinox.artifact.md5.comparator"/>
</extension>
+
+ <extension point="org.eclipse.ant.core.antTasks">
+
+ <antTask
+ library="ant_tasks/artifactRepository-ant.jar"
+ name="eclipse.p2.CompositeArtifactRepository.addChild"
+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.AddChildTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/artifactRepository-ant.jar"
+ name="eclipse.p2.CompositeArtifactRepository.create"
+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.CreateCompositeArtifactRepositoryTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/artifactRepository-ant.jar"
+ name="eclipse.p2.artifactMirrorApplication"
+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.MirrorApplicationTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/artifactRepository-ant.jar"
+ name="eclipse.p2.CompositeArtifactRepository.removeAllChildren"
+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.RemoveAllChildrenTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/artifactRepository-ant.jar"
+ name="eclipse.p2.CompositeArtifactRepository.removeChild"
+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.RemoveChildTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/artifactRepository-ant.jar"
+ name="eclipse.p2.CompositeArtifactRepository.validate"
+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.ValidateTask">
+ </antTask>
+
+ </extension>
+
</plugin>
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
new file mode 100644
index 000000000..a2e122805
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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/CreateCompositeArtifactRepositoryTask.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java
new file mode 100644
index 000000000..975857d75
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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.core.helpers.ServiceHelper;
+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.core.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;
+ 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);
+
+ // 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;
+ }
+
+}
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
new file mode 100644
index 000000000..7d3298fb2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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.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_DESTINATION = "-destination"; //$NON-NLS-1$
+ private static final String ARG_IGNORE_ERRORS = "-ignoreErrors"; //$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;
+ URL baseline; // location of known good repository for compare against (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 {
+ new MirrorApplication().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};
+
+ 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 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 write mode. (e.g. clean or append)
+ */
+ public void setWriteMode(String value) {
+ writeMode = 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/RemoveAllChildrenTask.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveAllChildrenTask.java
new file mode 100644
index 000000000..2b0474018
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveAllChildrenTask.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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 all the children from an existing composite artifact repository.
+ */
+public class RemoveAllChildrenTask extends Task {
+ URI location; // location of the composite repository
+
+ /* (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 = null;
+ try {
+ repo = (CompositeArtifactRepository) manager.loadRepository(location, null);
+ } catch (ProvisionException e) {
+ throw new BuildException("Error occurred while loading repository.", e);
+ }
+
+ // remove all children
+ repo.removeAllChildren();
+ }
+
+ /*
+ * Set the repository location.
+ */
+ public void setLocation(String value) throws URISyntaxException {
+ location = URIUtil.fromString(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
new file mode 100644
index 000000000..472c933c6
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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; // address of child to remove
+
+ /* (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 the child
+ 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);
+ }
+}
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
new file mode 100644
index 000000000..96a4d3a7e
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath b/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath
index 2fbb7a23e..ef379494d 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath
@@ -3,5 +3,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" output="bin_ant" path="src_ant"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch b/bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch
new file mode 100644
index 000000000..864bdafe5
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.equinox.p2.metadata.repository/buildAntTasks.xml"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.equinox.p2.metadata.repository"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.equinox.p2.metadata.repository/buildAntTasks.xml}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration>
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/.project b/bundles/org.eclipse.equinox.p2.metadata.repository/.project
index d382ba838..b1aa25ac4 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/.project
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/.project
@@ -25,6 +25,16 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>LaunchConfigHandle</key>
+ <value>&lt;project&gt;/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties b/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
index 3eeba1613..7a8c0c188 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007 IBM Corporation and others.
+# Copyright (c) 2007, 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
@@ -14,6 +14,12 @@ bin.includes = META-INF/,\
.,\
about.html,\
plugin.xml,\
- plugin.properties
+ plugin.properties,\
+ ant_tasks/metadataRepository-ant.jar
src.includes = about.html,\
schema/
+jars.extra.classpath = platform:/plugin/org.apache.ant/lib/ant.jar
+jars.compile.order = .,\
+ ant_tasks/metadataRepository-ant.jar
+source.ant_tasks/metadataRepository-ant.jar = src_ant/
+output.ant_tasks/metadataRepository-ant.jar = bin_ant/
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/buildAntTasks.xml b/bundles/org.eclipse.equinox.p2.metadata.repository/buildAntTasks.xml
new file mode 100644
index 000000000..f7d1a20b4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/buildAntTasks.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.equinox.p2.metadata.generator" default="default" basedir=".">
+
+ <target name="default" description="Compile ant tasks" >
+ <mkdir dir="${basedir}/ant_tasks" />
+ <delete file="${basedir}/ant_tasks/metadataRepository-ant.jar" failonerror="false"/>
+ <jar destfile="${basedir}/ant_tasks/metadataRepository-ant.jar" basedir="${basedir}/bin_ant"/>
+ </target>
+</project> \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml b/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml
index c32354054..566a702cd 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml
@@ -22,4 +22,38 @@
<filter suffix="compositeContent.xml"/>
<factory class="org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepositoryFactory"/>
</extension>
+
+ <extension point="org.eclipse.ant.core.antTasks">
+ <antTask
+ library="ant_tasks/metadataRepository-ant.jar"
+ name="eclipse.p2.CompositeMetadataRepository.addChild"
+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.AddChildTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/metadataRepository-ant.jar"
+ name="eclipse.p2.CompositeMetadataRepository.create"
+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.CreateCompositeMetadataRepositoryTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/metadataRepository-ant.jar"
+ name="eclipse.p2.metadataMirrorApplication"
+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.MirrorApplicationTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/metadataRepository-ant.jar"
+ name="eclipse.p2.CompositeMetadataRepository.removeAllChildren"
+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.RemoveAllChildrenTask">
+ </antTask>
+
+ <antTask
+ library="ant_tasks/metadataRepository-ant.jar"
+ name="eclipse.p2.CompositeMetadataRepository.removeChild"
+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.RemoveChildTask">
+ </antTask>
+
+ </extension>
+
</plugin>
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java
new file mode 100644
index 000000000..a19d18a60
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.metadata.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.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
+import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+
+/**
+ * Ant task for adding a child repository to a composite metadata repository.
+ */
+public class AddChildTask extends Task {
+
+ URI location; // location of the composite repository
+ URI child; // address of the child to add
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() {
+ validate();
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ if (manager == null)
+ throw new BuildException("Unable to aquire metadata repository manager service.");
+
+ // load the composite repository
+ CompositeMetadataRepository repo = null;
+ try {
+ repo = (CompositeMetadataRepository) manager.loadRepository(location, null);
+ } catch (ClassCastException e) {
+ throw new BuildException("Repository at location: " + location + " is not a composite metadata repository.");
+ } catch (ProvisionException e) {
+ throw new BuildException("Error occurred while loading repository.", e);
+ }
+
+ // add the child
+ repo.addChild(child);
+ manager.removeRepository(location);
+ }
+
+ /*
+ * Validate user input to ensure we have enough information to go forward.
+ */
+ private void validate() {
+ if (location == null)
+ throw new BuildException("Need to specify the composite repository location.");
+ if (child == null)
+ throw new BuildException("Need to specify the child repository location.");
+ }
+
+ /*
+ * 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);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java
new file mode 100644
index 000000000..082503eba
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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.metadata.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.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+
+/**
+ * Ant task for creating a new composite metadata repository.
+ */
+public class CreateCompositeMetadataRepositoryTask extends Task {
+
+ URI location; // desired location of the composite repository
+ String name = "Composite Metadata Repository";
+ boolean compressed = true; // compress by default
+ Map properties = new HashMap();
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() {
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ if (manager == null)
+ throw new BuildException("Unable to aquire metadata repository manager service.");
+
+ // remove the repo first.
+ manager.removeRepository(location);
+
+ // create the properties
+ if (compressed)
+ properties.put(IRepository.PROP_COMPRESSED, Boolean.toString(true));
+
+ // create the repository
+ try {
+ manager.createRepository(location, name, IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, properties);
+ } catch (ProvisionException e) {
+ throw new BuildException("Error occurred while creating composite metadata repository.", e);
+ }
+ }
+
+ /*
+ * Set the name of the composite repository.
+ */
+ public void setName(String value) {
+ name = value;
+ }
+
+ /*
+ * Set the repository location.
+ */
+ public void setLocation(String value) throws URISyntaxException {
+ location = URIUtil.fromString(value);
+ }
+
+ /*
+ * Set whether or not this repository should be compressed.
+ */
+ public void setCompressed(boolean value) {
+ compressed = value;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java
new file mode 100644
index 000000000..c5941562f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * 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.metadata.repository.ant;
+
+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.metadata.mirror.MirrorApplication;
+import org.osgi.framework.Bundle;
+
+/**
+ * Ant task for running the metadata mirror application.
+ */
+public class MirrorApplicationTask extends Task {
+
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private static final String ARG_DESTINATION = "-destination"; //$NON-NLS-1$
+ private static final String ARG_SOURCE = "-source"; //$NON-NLS-1$
+ private static final String ARG_WRITE_MODE = "-writeMode"; //$NON-NLS-1$
+ URL source;
+ URL destination;
+ String writeMode;
+
+ //TODO add transitive and roots attributed when implemented.
+
+ /*
+ * Run the mirror application with the given arguments.
+ */
+ private void runMirrorApplication(final String[] args) throws Exception {
+ new MirrorApplication().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() {
+ // create arguments
+ String[] args = new String[] { //
+ ARG_SOURCE, source.toExternalForm(), //
+ ARG_DESTINATION, destination.toExternalForm(), //
+ ARG_WRITE_MODE, writeMode == null ? EMPTY_STRING : writeMode};
+
+ try {
+ runMirrorApplication(args);
+ } catch (Exception e) {
+ throw new BuildException("Error occurred while running metadata mirror application.", e);
+ }
+ }
+
+ /*
+ * Set the source location.
+ */
+ public void setSource(String value) throws MalformedURLException {
+ source = new URL(value);
+ }
+
+ /*
+ * Set the destination location.
+ */
+ public void setDestination(String value) throws MalformedURLException {
+ destination = new URL(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.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java
new file mode 100644
index 000000000..aad9b8984
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.metadata.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.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
+import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+
+/**
+ * Ant task to remove all the children repositories from a composite metadata repository.
+ */
+public class RemoveAllChildrenTask extends Task {
+ URI location; // location of the composite repository
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() {
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ if (manager == null)
+ throw new BuildException("Unable to aquire metadata repository manager service.");
+
+ // load the repository
+ CompositeMetadataRepository repo = null;
+ try {
+ repo = (CompositeMetadataRepository) manager.loadRepository(location, null);
+ } catch (ProvisionException e) {
+ throw new BuildException("Exception while loading repository.", e);
+ }
+
+ // remove all children
+ repo.removeAllChildren();
+ }
+
+ /*
+ * Set the repository location.
+ */
+ public void setLocation(String value) throws URISyntaxException {
+ location = URIUtil.fromString(value);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java
new file mode 100644
index 000000000..0c214e7a5
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.metadata.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.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.metadata.repository.Activator;
+import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+
+/**
+ * Ant task to remove a specific child repository from a composite metadata repository.
+ */
+public class RemoveChildTask extends Task {
+
+ URI location; // location of the composite repository
+ URI child; // address of the child to be removed
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() {
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ if (manager == null)
+ throw new BuildException("Unable to aquire metadata repository manager service.");
+
+ CompositeMetadataRepository repo;
+ try {
+ repo = (CompositeMetadataRepository) manager.loadRepository(location, null);
+ } catch (ProvisionException e) {
+ throw new BuildException("Error occurred while loading repository.", e);
+ }
+ repo.removeChild(child);
+ }
+
+ /*
+ * 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 to remove.
+ */
+ public void setChild(String value) throws URISyntaxException {
+ child = URIUtil.fromString(value);
+ }
+}

Back to the top