Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 120876 Details for
Bug 255913
[mirror] Need ant tasks for mirroring and composite repositories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Slight improvement over previous patch
255913Update2.txt (text/plain), 41.82 KB, created by
Andrew Cattle
on 2008-12-18 14:25:28 EST
(
hide
)
Description:
Slight improvement over previous patch
Filename:
MIME Type:
Creator:
Andrew Cattle
Created:
2008-12-18 14:25:28 EST
Size:
41.82 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.artifact.repository >Index: .classpath >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.artifact.repository/.classpath,v >retrieving revision 1.4 >diff -u -r1.4 .classpath >--- .classpath 21 Feb 2008 22:42:40 -0000 1.4 >+++ .classpath 18 Dec 2008 19:21:13 -0000 >@@ -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> >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml,v >retrieving revision 1.11 >diff -u -r1.11 plugin.xml >--- plugin.xml 20 Nov 2008 00:09:50 -0000 1.11 >+++ plugin.xml 18 Dec 2008 19:21:13 -0000 >@@ -43,4 +43,42 @@ > <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.artifactMirrorApplication" >+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.MirrorApplicationTask"> >+ </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.CompositeArtifactRepository.addChild" >+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.AddChildTask"> >+ </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.removeAllChildren" >+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.RemoveAllChildrenTask"> >+ </antTask> >+ >+ <antTask >+ library="ant_tasks/artifactRepository-ant.jar" >+ name="eclipse.p2.CompositeArtifactRepository.sanityCheck" >+ class="org.eclipse.equinox.internal.p2.artifact.repository.ant.SanityCheckTask"> >+ </antTask> >+ </extension> > </plugin> >Index: build.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.artifact.repository/build.properties,v >retrieving revision 1.3 >diff -u -r1.3 build.properties >--- build.properties 29 Oct 2007 15:33:43 -0000 1.3 >+++ build.properties 18 Dec 2008 19:21:13 -0000 >@@ -14,6 +14,12 @@ > .,\ > 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/ >Index: .project >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.artifact.repository/.project,v >retrieving revision 1.2 >diff -u -r1.2 .project >--- .project 30 Sep 2007 18:55:28 -0000 1.2 >+++ .project 18 Dec 2008 19:21:13 -0000 >@@ -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><project>/.externalToolBuilders/org.eclipse.equinox.p2.artifact.repository buildAntTasks.xml.launch</value> >+ </dictionary> >+ </arguments> >+ </buildCommand> > </buildSpec> > <natures> > <nature>org.eclipse.pde.PluginNature</nature> >Index: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/CreateCompositeArtifactRepositoryTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+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(); >+ >+ public void execute() { >+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); >+ if (manager == null) >+ throw new BuildException("Unable to aquire RepositoryManager."); >+ >+ //remove the repo first. >+ manager.removeRepository(location); >+ >+ //create the properties >+ if (compressed) >+ properties.put(IRepository.PROP_COMPRESSED, "true"); >+ >+ //create the repository >+ try { >+ manager.createRepository(location, name, IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, properties); >+ } catch (ProvisionException e) { >+ throw new BuildException("Exception while creating composite artifact repository.", e); >+ } >+ } >+ >+ public void setName(String value) { >+ name = value; >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+ >+ public void setCompressed(boolean value) { >+ compressed = value; >+ } >+ >+} >Index: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/MirrorApplicationTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,135 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+public class MirrorApplicationTask extends Task { >+ URL source; >+ URL destination; >+ URL baseline; //location of known good repository for compare against. Not required >+ String comparatorID; //specifies a comparator. Not required >+ String message = ""; >+ String writeMode; >+ boolean compare = false; >+ boolean ignoreErrors = false; >+ boolean raw = false; //use raw artifact descriptors? >+ boolean verbose = false; >+ >+ /** >+ * runs the mirror application with arguments args >+ */ >+ private void runMirrorApplication(String msg, final String[] args) throws Exception { >+ MirrorApplication application = new MirrorApplication(); >+ application.start(new IApplicationContext() { >+ >+ public void applicationRunning() { >+ } >+ >+ 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; >+ } >+ }); >+ } >+ >+ public void execute() { >+ //Compare against if baseline specified >+ boolean compareAgainst = baseline != null; >+ boolean comparator = comparatorID != null; >+ //create arguments >+ String[] args = new String[] {"-source", source.toExternalForm(), "-destination", destination.toExternalForm(), "-writeMode", writeMode == null ? "" : writeMode, compare ? "-compare" : "", ignoreErrors ? "-ignoreErrors" : "", raw ? "-raw" : "", verbose ? "-verbose" : "", compareAgainst ? "-compareAgainst" : "", compareAgainst ? baseline.toExternalForm() : "", comparator ? "-comparator" : "", comparator ? comparatorID : ""}; >+ >+ try { >+ runMirrorApplication(message, args); >+ } catch (Exception e) { >+ throw new BuildException("Exception while running mirror application.", e); >+ } >+ } >+ >+ public void setSource(String value) throws MalformedURLException { >+ source = new URL(value); >+ } >+ >+ public void setDestination(String value) throws MalformedURLException { >+ destination = new URL(value); >+ } >+ >+ public void setBaseline(String value) throws MalformedURLException { >+ baseline = new URL(value); >+ compare = true; >+ } >+ >+ public void setComparatorID(String value) { >+ comparatorID = value; >+ compare = true; >+ } >+ >+ public void setMessage(String value) { >+ message = value; >+ } >+ >+ public void setWriteMode(String value) { >+ writeMode = value; >+ } >+ >+ public void setCompare(boolean value) { >+ compare = value; >+ } >+ >+ public void setIgnoreErrors(boolean value) { >+ ignoreErrors = value; >+ } >+ >+ public void setRaw(boolean value) { >+ raw = value; >+ } >+ >+ public void setVerbose(boolean value) { >+ verbose = value; >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveAllChildrenTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveAllChildrenTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveAllChildrenTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveAllChildrenTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+public class RemoveAllChildrenTask extends Task { >+ URI location; //location of the composite repository >+ >+ public void execute() { >+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); >+ if (manager == null) >+ throw new BuildException("Unable to aquire RepositoryManager."); >+ >+ //load repository >+ CompositeArtifactRepository repo = null; >+ try { >+ repo = (CompositeArtifactRepository) manager.loadRepository(location, null); >+ } catch (ProvisionException e) { >+ throw new BuildException("Exception while loading repository.", e); >+ } >+ >+ //remove all children >+ repo.removeAllChildren(); >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/AddChildTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+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. Not required >+ >+ public void execute() { >+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); >+ if (manager == null) >+ throw new BuildException("Unable to aquire RepositoryManager."); >+ >+ //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); >+ } >+ >+ //assumes that specifying a comparatorID means we want to compare >+ if (comparatorID != null) { >+ if (repo.addChild(child, comparatorID)) >+ System.out.println(child + " was added successfully"); >+ else >+ System.out.println(child + " was not added"); >+ } else { >+ repo.addChild(child); >+ } >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+ >+ public void setChild(String value) throws URISyntaxException { >+ child = URIUtil.fromString(value); >+ } >+ >+ public void setComparatorID(String value) { >+ comparatorID = value; >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/ValidateTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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.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; >+ >+public class ValidateTask { >+ URI location; //location of the composite repository >+ String comparatorID; //specifies the comparator we want to use. >+ >+ public void execute() { >+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); >+ if (manager == null) >+ throw new BuildException("Unable to aquire RepositoryManager."); >+ >+ //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("Sanity Check is OK"); >+ else >+ System.err.println("Sanity Check failed"); >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+ >+ public void setComparatorID(String value) { >+ comparatorID = value; >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/artifact/repository/ant/RemoveChildTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,51 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+public class RemoveChildTask extends Task { >+ URI location; //location of the composite repository >+ URI child; //address of child to remove >+ >+ public void execute() { >+ IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); >+ >+ //load repository >+ CompositeArtifactRepository repo; >+ try { >+ repo = (CompositeArtifactRepository) manager.loadRepository(location, null); >+ } catch (ProvisionException e) { >+ throw new BuildException("Exception while loading repository.", e); >+ } >+ >+ //remove the child >+ repo.removeChild(child); >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+ >+ public void setChild(String value) throws URISyntaxException { >+ child = URIUtil.fromString(value); >+ } >+} >#P org.eclipse.equinox.p2.metadata.repository >Index: build.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/build.properties,v >retrieving revision 1.3 >diff -u -r1.3 build.properties >--- build.properties 29 Oct 2007 15:33:35 -0000 1.3 >+++ build.properties 18 Dec 2008 19:21:15 -0000 >@@ -14,6 +14,12 @@ > .,\ > 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/ >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/plugin.xml,v >retrieving revision 1.6 >diff -u -r1.6 plugin.xml >--- plugin.xml 13 Nov 2008 20:42:50 -0000 1.6 >+++ plugin.xml 18 Dec 2008 19:21:15 -0000 >@@ -22,4 +22,36 @@ > <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.metadataMirrorApplication" >+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.MirrorApplicationTask"> >+ </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.CompositeMetadataRepository.addChild" >+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.AddChildTask"> >+ </antTask> >+ >+ <antTask >+ library="ant_tasks/metadataRepository-ant.jar" >+ name="eclipse.p2.CompositeMetadataRepository.removeChild" >+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.RemoveChildTask"> >+ </antTask> >+ >+ <antTask >+ library="ant_tasks/metadataRepository-ant.jar" >+ name="eclipse.p2.CompositeMetadataRepository.removeAllChildren" >+ class="org.eclipse.equinox.internal.p2.metadata.repository.ant.RemoveAllChildrenTask"> >+ </antTask> >+ </extension> > </plugin> >Index: .classpath >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/.classpath,v >retrieving revision 1.3 >diff -u -r1.3 .classpath >--- .classpath 22 Feb 2008 16:28:58 -0000 1.3 >+++ .classpath 18 Dec 2008 19:21:15 -0000 >@@ -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> >Index: .project >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/.project,v >retrieving revision 1.3 >diff -u -r1.3 .project >--- .project 6 Mar 2008 23:13:54 -0000 1.3 >+++ .project 18 Dec 2008 19:21:15 -0000 >@@ -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><project>/.externalToolBuilders/org.eclipse.equinox.p2.metadata.reposiroy buildAntTasks.xml.launch</value> >+ </dictionary> >+ </arguments> >+ </buildCommand> > </buildSpec> > <natures> > <nature>org.eclipse.pde.PluginNature</nature> >Index: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/AddChildTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+public class AddChildTask extends Task { >+ URI location; //location of the composite repository >+ URI child; //address of the child to add >+ >+ public void execute() { >+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); >+ if (manager == null) >+ throw new BuildException("Unable to aquire RepositoryManager."); >+ >+ //load the composite repository >+ CompositeMetadataRepository repo = null; >+ try { >+ repo = (CompositeMetadataRepository) manager.loadRepository(location, null); >+ } catch (ProvisionException e) { >+ throw new BuildException("Exception while loading repository.", e); >+ } >+ >+ //add the child >+ repo.addChild(child); >+ >+ manager.removeRepository(location); >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+ >+ public void setChild(String value) throws URISyntaxException { >+ child = URIUtil.fromString(value); >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveChildTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+public class RemoveChildTask extends Task { >+ URI location; //location of the composite repository >+ URI child; //address of the child to be removed >+ >+ public void execute() { >+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); >+ >+ CompositeMetadataRepository repo; >+ try { >+ repo = (CompositeMetadataRepository) manager.loadRepository(location, null); >+ } catch (ProvisionException e) { >+ throw new BuildException("Exception while loading repository.", e); >+ } >+ repo.removeChild(child); >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+ >+ public void setChild(String value) throws URISyntaxException { >+ child = URIUtil.fromString(value); >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/RemoveAllChildrenTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+public class RemoveAllChildrenTask extends Task { >+ URI location; //location of the composite repository >+ >+ public void execute() { >+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); >+ if (manager == null) >+ throw new BuildException("Unable to aquire RepositoryManager."); >+ >+ //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(); >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/CreateCompositeMetadataRepositoryTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+public class CreateCompositeMetadataRepositoryTask extends Task { >+ URI location; //desired location of the composite repository >+ String name = "Composite Metadata Repository"; >+ boolean compressed = true; >+ Map properties = new HashMap(); >+ >+ public void execute() { >+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); >+ if (manager == null) >+ throw new BuildException("Unable to aquire RepositoryManager."); >+ >+ //remove the repo first. >+ manager.removeRepository(location); >+ >+ //create the properties >+ if (compressed) >+ properties.put(IRepository.PROP_COMPRESSED, "true"); >+ >+ //create the repository >+ try { >+ manager.createRepository(location, name, IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, properties); >+ } catch (ProvisionException e) { >+ throw new BuildException("Exception while creating composite artifact repository.", e); >+ } >+ } >+ >+ public void setName(String value) { >+ name = value; >+ } >+ >+ public void setLocation(String value) throws URISyntaxException { >+ location = URIUtil.fromString(value); >+ } >+ >+ public void setCompressed(boolean value) { >+ compressed = value; >+ } >+ >+} >Index: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/metadata/repository/ant/MirrorApplicationTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,102 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 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; >+ >+public class MirrorApplicationTask extends Task { >+ URL source; >+ URL destination; >+ String message = ""; >+ String writeMode; >+ >+ //TODO add transitive and roots attributed when implemented. >+ >+ /** >+ * runs the mirror application with arguments args >+ */ >+ private void runMirrorApplication(String msg, final String[] args) throws Exception { >+ MirrorApplication application = new MirrorApplication(); >+ application.start(new IApplicationContext() { >+ >+ public void applicationRunning() { >+ } >+ >+ 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; >+ } >+ }); >+ } >+ >+ public void execute() { >+ //create arguments >+ String[] args = new String[] {"-source", source.toExternalForm(), "-destination", destination.toExternalForm(), "-writeMode", writeMode == null ? "" : writeMode}; >+ >+ try { >+ runMirrorApplication(message, args); >+ } catch (Exception e) { >+ throw new BuildException("Exception while running mirror application.", e); >+ } >+ } >+ >+ public void setSource(String value) throws MalformedURLException { >+ source = new URL(value); >+ } >+ >+ public void setDestination(String value) throws MalformedURLException { >+ destination = new URL(value); >+ } >+ >+ public void setMessage(String value) { >+ message = value; >+ } >+ >+ public void setWriteMode(String value) { >+ writeMode = value; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 255913
:
119374
|
120212
|
120876
|
120947
|
122471