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 127893 Details for
Bug 265550
Review Ant task consistency
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]
Updated p2 Ant Tasks
AntTasks.patch (text/plain), 44.01 KB, created by
Matthew Piggott
on 2009-03-06 19:48:52 EST
(
hide
)
Description:
Updated p2 Ant Tasks
Filename:
MIME Type:
Creator:
Matthew Piggott
Created:
2009-03-06 19:48:52 EST
Size:
44.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.repository.tools >Index: src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java,v >retrieving revision 1.4 >diff -u -r1.4 MirrorApplication.java >--- src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java 22 Feb 2009 20:00:30 -0000 1.4 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java 7 Mar 2009 00:48:16 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.internal.repository.tools; > >+import java.net.URI; > import java.util.ArrayList; > import java.util.Iterator; > import org.eclipse.core.runtime.*; >@@ -17,16 +18,28 @@ > import org.eclipse.equinox.app.IApplicationContext; > import org.eclipse.equinox.internal.p2.artifact.mirror.Mirroring; > import org.eclipse.equinox.internal.p2.director.PermissiveSlicer; >+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; >+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepositoryManager; > import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; > import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; > import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; >+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; > import org.eclipse.equinox.internal.provisional.p2.query.Collector; > import org.eclipse.equinox.internal.provisional.p2.query.IQueryable; > > public class MirrorApplication extends AbstractApplication { > protected SlicingOptions slicingOptions = new SlicingOptions(); > >+ private URI baseline; >+ //private URI baseline; >+ private String comparatorID; >+ private boolean compare = false; >+ private boolean failOnError = true; >+ private boolean raw = true; >+ private boolean verbose = false; >+ > public Object start(IApplicationContext context) throws Exception { > run(null); > return IApplication.EXIT_OK; >@@ -36,19 +49,23 @@ > try { > validate(); > initializeRepos(new NullProgressMonitor()); >+ intializeIUs(); > IQueryable slice = slice(new NullProgressMonitor()); >- IStatus mirrorStatus = mirrorArtifacts(slice, new NullProgressMonitor()); >- if (mirrorStatus.getSeverity() == IStatus.ERROR) { >- return mirrorStatus; >+ if (destinationArtifactRepository != null) { >+ IStatus mirrorStatus = mirrorArtifacts(slice, new NullProgressMonitor()); >+ if (mirrorStatus.getSeverity() == IStatus.ERROR) { >+ return mirrorStatus; >+ } > } >- mirrorMetadata(slice, new NullProgressMonitor()); >+ if (destinationMetadataRepository != null) >+ mirrorMetadata(slice, new NullProgressMonitor()); > } finally { > finalizeRepositories(); > } > return Status.OK_STATUS; > } > >- private IStatus mirrorArtifacts(IQueryable slice, IProgressMonitor monitor) { >+ private IStatus mirrorArtifacts(IQueryable slice, IProgressMonitor monitor) throws ProvisionException { > Collector ius = slice.query(InstallableUnitQuery.ANY, new Collector(), monitor); > ArrayList keys = new ArrayList(ius.size()); > for (Iterator iterator = ius.iterator(); iterator.hasNext();) { >@@ -58,9 +75,24 @@ > keys.add(iuKeys[i]); > } > } >- Mirroring mirror = new Mirroring(getCompositeArtifactRepository(), destinationArtifactRepository, true); >+ Mirroring mirror = new Mirroring(getCompositeArtifactRepository(), destinationArtifactRepository, raw); >+ >+ mirror.setCompare(compare); >+ mirror.setComparatorId(comparatorID); >+ mirror.setBaseline(initializeBaseline()); > mirror.setArtifactKeys((IArtifactKey[]) keys.toArray(new IArtifactKey[keys.size()])); >- return mirror.run(true, false); >+ >+ return mirror.run(failOnError, verbose); >+ } >+ >+ private IArtifactRepository initializeBaseline() throws ProvisionException { >+ if (baseline == null) >+ return null; >+ IArtifactRepositoryManager mgr = Activator.getArtifactRepositoryManager(); >+ >+ if (!mgr.contains(baseline)) >+ artifactReposToRemove.add(baseline); >+ return mgr.loadRepository(baseline, IRepositoryManager.REPOSITORY_HINT_MODIFIABLE, null); > } > > private void mirrorMetadata(IQueryable slice, IProgressMonitor monitor) { >@@ -77,9 +109,28 @@ > private void validate() throws ProvisionException { > if (sourceMetadataRepositories == null) > throw new ProvisionException("Need to set the source metadata repository location."); >- if (sourceIUs == null) >- throw new ProvisionException("Mirroring root needs to be specified."); >- //TODO Check that the IU is in repo >+ } >+ >+ /* >+ * If no IUs have been specified we want to mirror them all >+ */ >+ private void intializeIUs() throws ProvisionException { >+ if (sourceIUs == null || sourceIUs.isEmpty()) { >+ sourceIUs = new ArrayList(); >+ IMetadataRepository metadataRepo = getCompositeMetadataRepository(); >+ Collector collector = metadataRepo.query(InstallableUnitQuery.ANY, new Collector(), null); >+ >+ for (Iterator iter = collector.iterator(); iter.hasNext();) { >+ IInstallableUnit iu = (IInstallableUnit) iter.next(); >+ sourceIUs.add(iu); >+ } >+ >+ if (collector.size() == 0) { >+ throw new ProvisionException("No IUs specified and no IUs obtained from metadata repositories."); >+ } >+ } else { >+ //TODO Check that the IU is in repo >+ } > } > > private IQueryable slice(IProgressMonitor monitor) { >@@ -92,4 +143,48 @@ > public void setSlicingOptions(SlicingOptions options) { > slicingOptions = options; > } >+ >+ /* >+ * Set the location of the baseline repository. (used in comparison) >+ */ >+ public void setBaseline(URI baseline) { >+ this.baseline = baseline; >+ compare = true; >+ } >+ >+ /* >+ * Set the identifier of the comparator to use. >+ */ >+ public void setComparatorID(String value) { >+ comparatorID = value; >+ compare = true; >+ } >+ >+ /* >+ * 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) { >+ failOnError = !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; >+ } > } >Index: src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java,v >retrieving revision 1.2 >diff -u -r1.2 RepositoryDescriptor.java >--- src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java 17 Feb 2009 21:02:59 -0000 1.2 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java 7 Mar 2009 00:48:16 -0000 >@@ -15,12 +15,14 @@ > > public class RepositoryDescriptor { > >+ public static final int TYPE_BOTH = -1; >+ > private boolean compressed = true; > private boolean append = true; > private String name = null; > private URI location = null; > private String format = null; >- private int kind; >+ private int kind = TYPE_BOTH; > > public void setCompressed(boolean compress) { > compressed = compress; >Index: src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java,v >retrieving revision 1.5 >diff -u -r1.5 AbstractApplication.java >--- src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java 3 Mar 2009 00:13:54 -0000 1.5 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java 7 Mar 2009 00:48:16 -0000 >@@ -28,6 +28,7 @@ > > protected List sourceArtifactRepositories = new ArrayList(); > protected List sourceMetadataRepositories = new ArrayList(); >+ protected List sourceRepositories = new ArrayList(); > protected List artifactReposToRemove = new ArrayList(); > protected List metadataReposToRemove = new ArrayList(); > protected List sourceIUs = new ArrayList(); >@@ -79,6 +80,16 @@ > } > > public void initializeRepos(IProgressMonitor progress) throws ProvisionException { >+ for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ if (repo.getKind() == IRepository.TYPE_ARTIFACT) { >+ sourceArtifactRepositories.add(repo.getRepoLocation()); >+ } else if (repo.getKind() == IRepository.TYPE_METADATA) { >+ sourceMetadataRepositories.add(repo.getRepoLocation()); >+ } else >+ throw new ProvisionException("Repository of unknown type: " + repo.getRepoLocation()); >+ >+ } > IArtifactRepositoryManager artifactRepositoryManager = Activator.getArtifactRepositoryManager(); > if (sourceArtifactRepositories != null && !sourceArtifactRepositories.isEmpty()) { > for (Iterator iter = sourceArtifactRepositories.iterator(); iter.hasNext();) { >@@ -100,22 +111,40 @@ > } > > processDestinationRepos(artifactRepositoryManager, metadataRepositoryManager); >- > } > > private void processDestinationRepos(IArtifactRepositoryManager artifactRepositoryManager, IMetadataRepositoryManager metadataRepositoryManager) throws ProvisionException { >- if (destinationRepos.size() != 2) { >- throw new ProvisionException("Too many or too few destination repositories."); >+ RepositoryDescriptor artifactRepoDescriptor = null; >+ RepositoryDescriptor metadataRepoDescriptor = null; >+ >+ Iterator iter = destinationRepos.iterator(); >+ while (iter.hasNext() && (artifactRepoDescriptor == null || metadataRepoDescriptor == null)) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ int kind = repo.getKind(); >+ if (kind == IRepository.TYPE_ARTIFACT && artifactRepoDescriptor == null) >+ artifactRepoDescriptor = repo; >+ else if (kind == IRepository.TYPE_METADATA && metadataRepoDescriptor == null) >+ metadataRepoDescriptor = repo; >+ else if (kind == RepositoryDescriptor.TYPE_BOTH) { >+ if (artifactRepoDescriptor == null) >+ artifactRepoDescriptor = repo; >+ if (metadataRepoDescriptor == null) >+ metadataRepoDescriptor = repo; >+ } > } >- RepositoryDescriptor artifactRepoDescriptor = ((RepositoryDescriptor) destinationRepos.get(0)).getKind() == IRepository.TYPE_ARTIFACT ? ((RepositoryDescriptor) destinationRepos.get(0)) : ((RepositoryDescriptor) destinationRepos.get(1)); >- RepositoryDescriptor metadataRepoDescriptor = ((RepositoryDescriptor) destinationRepos.get(0)).getKind() == IRepository.TYPE_METADATA ? ((RepositoryDescriptor) destinationRepos.get(0)) : ((RepositoryDescriptor) destinationRepos.get(1)); >- destinationArtifactRepository = initializeDestination(artifactRepoDescriptor, artifactRepositoryManager); >- destinationMetadataRepository = initializeDestination(metadataRepoDescriptor, metadataRepositoryManager); >+ >+ if (artifactRepoDescriptor != null) >+ destinationArtifactRepository = initializeDestination(artifactRepoDescriptor, artifactRepositoryManager); >+ if (metadataRepoDescriptor != null) >+ destinationMetadataRepository = initializeDestination(metadataRepoDescriptor, metadataRepositoryManager); >+ >+ if (destinationMetadataRepository == null && destinationArtifactRepository == null) >+ throw new ProvisionException("Unable to locate a valid destiation repository."); > } > > private IMetadataRepository initializeDestination(RepositoryDescriptor toInit, IMetadataRepositoryManager mgr) throws ProvisionException { > try { >- if (mgr.contains(toInit.getRepoLocation())) >+ if (!mgr.contains(toInit.getRepoLocation())) > metadataReposToRemove.add(toInit.getRepoLocation()); > IMetadataRepository repository = mgr.loadRepository(toInit.getRepoLocation(), IRepositoryManager.REPOSITORY_HINT_MODIFIABLE, null); > if (repository != null && repository.isModifiable()) { >@@ -148,7 +177,7 @@ > > private IArtifactRepository initializeDestination(RepositoryDescriptor toInit, IArtifactRepositoryManager mgr) throws ProvisionException { > try { >- if (mgr.contains(toInit.getRepoLocation())) >+ if (!mgr.contains(toInit.getRepoLocation())) > artifactReposToRemove.add(toInit.getRepoLocation()); > IArtifactRepository repository = mgr.loadRepository(toInit.getRepoLocation(), IRepositoryManager.REPOSITORY_HINT_MODIFIABLE, null); > if (repository != null && repository.isModifiable()) { >@@ -212,4 +241,8 @@ > public void addDestination(RepositoryDescriptor descriptor) { > destinationRepos.add(descriptor); > } >+ >+ public void addSource(RepositoryDescriptor repo) { >+ sourceRepositories.add(repo); >+ } > } >\ No newline at end of file >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java,v >retrieving revision 1.2 >diff -u -r1.2 AbstractRepositoryTask.java >--- src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java 20 Feb 2009 17:05:06 -0000 1.2 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java 7 Mar 2009 00:48:16 -0000 >@@ -30,15 +30,6 @@ > protected List sourceRepos = new ArrayList(); > protected List destinations = new ArrayList(); > >- /* >- * Create a special file set since the user specified a "source" sub-element. >- */ >- public FileSet createSource() { >- MyFileSet set = new MyFileSet(); >- sourceRepos.add(set); >- return set; >- } >- > protected void addMetadataSourceRepository(URI repoLocation) { > application.addSourceMetadataRepository(repoLocation); > } >@@ -48,6 +39,32 @@ > } > > /* >+ * Add source repositories to mirror from >+ */ >+ public void addConfiguredSource(SourceList sourceList) { >+ for (Iterator iter = sourceList.getRepositoryList().iterator(); iter.hasNext();) { >+ DestinationRepository repo = (DestinationRepository) iter.next(); >+ application.addSource(repo.getDescriptor()); >+ } >+ >+ for (Iterator iter = sourceList.getFileSetList().iterator(); iter.hasNext();) { >+ FileSet fileSet = (FileSet) iter.next(); >+ sourceRepos.add(fileSet); >+ // Added to the application later through prepareSourceRepos >+ } >+ } >+ >+ /* >+ * Add a repository to mirror into >+ */ >+ public DestinationRepository createRepository() { >+ DestinationRepository destination = new DestinationRepository(); >+ destinations.add(destination); >+ application.addDestination(destination.getDescriptor()); >+ return destination; >+ } >+ >+ /* > * Create an object to hold IU information since the user specified an "iu" sub-element. > */ > public Object createIu() { >@@ -83,28 +100,6 @@ > destinations.add(artifact); > } > >- public DestinationRepository createDestination() { >- DestinationRepository destination = new DestinationRepository(); >- destinations.add(destination); >- application.addDestination(destination.getDescriptor()); >- return destination; >- } >- >- /* >- * New FileSet subclass which adds an optional "location" attribute. >- */ >- public class MyFileSet extends FileSet { >- String location; >- >- public MyFileSet() { >- super(); >- } >- >- public void setLocation(String value) { >- this.location = value; >- } >- } >- > /* > * If the user specified some source repositories via sub-elements > * then add them to the transformer for consideration. >@@ -113,33 +108,37 @@ > if (sourceRepos == null || sourceRepos.isEmpty()) > return; > for (Iterator iter = sourceRepos.iterator(); iter.hasNext();) { >- Object next = iter.next(); >- if (next instanceof MyFileSet) { >- MyFileSet fileset = (MyFileSet) next; >- // determine if the user set a "location" attribute or used a fileset >- if (fileset.location == null) { >- DirectoryScanner scanner = fileset.getDirectoryScanner(getProject()); >- String[][] elements = new String[][] {scanner.getIncludedDirectories(), scanner.getIncludedFiles()}; >- for (int i = 0; i < 2; i++) { >- for (int j = 0; j < elements[i].length; j++) { >- File file = new File(fileset.getDir(), elements[i][j]); >- URI uri = file.toURI(); >- >- if (file.isFile() && file.getName().endsWith(".zip")) { //$NON-NLS-1$ >- try { >- uri = new URI("jar:" + uri.toString() + "!/"); //$NON-NLS-1$ //$NON-NLS-2$ >- } catch (URISyntaxException e) { >- //? >- continue; >- } >- } >+ RepositoryFileSet fileset = (RepositoryFileSet) iter.next(); >+ >+ DirectoryScanner scanner = fileset.getDirectoryScanner(getProject()); >+ String[][] elements = new String[][] {scanner.getIncludedDirectories(), scanner.getIncludedFiles()}; >+ for (int i = 0; i < 2; i++) { >+ for (int j = 0; j < elements[i].length; j++) { >+ File file = new File(fileset.getDir(), elements[i][j]); >+ URI uri = file.toURI(); >+ >+ if (file.isFile() && file.getName().endsWith(".zip")) { //$NON-NLS-1$ >+ try { >+ uri = new URI("jar:" + uri.toString() + "!/"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } catch (URISyntaxException e) { >+ //? >+ continue; >+ } >+ } >+ switch (fileset.getKind()) { >+ case RepositoryFileSet.TYPE_BOTH : > application.addSourceArtifactRepository(uri); > application.addSourceMetadataRepository(uri); >- } >+ break; >+ case RepositoryFileSet.TYPE_ARTIFACT : >+ application.addSourceArtifactRepository(uri); >+ break; >+ case RepositoryFileSet.TYPE_METADATA : >+ application.addSourceMetadataRepository(uri); >+ break; >+ default : >+ throw new BuildException("Unknown repository type for: " + uri); > } >- } else { >- application.addSourceArtifactRepository(fileset.location); >- application.addSourceMetadataRepository(fileset.location); > } > } > } >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java,v >retrieving revision 1.3 >diff -u -r1.3 MirrorTask.java >--- src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java 22 Feb 2009 20:00:30 -0000 1.3 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/MirrorTask.java 7 Mar 2009 00:48:16 -0000 >@@ -10,9 +10,11 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.internal.repository.tools.tasks; > >+import java.net.URISyntaxException; > import java.util.List; > import org.apache.tools.ant.BuildException; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.URIUtil; > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; > import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication; > >@@ -44,4 +46,50 @@ > ((MirrorApplication) application).setSlicingOptions(options.getOptions()); > return options; > } >+ >+ /* >+ * Set the location of the baseline repository. (used in comparison) >+ */ >+ public void setBaseline(String value) { >+ try { >+ ((MirrorApplication) application).setBaseline(URIUtil.fromString(value)); >+ } catch (URISyntaxException e) { >+ throw new BuildException(e); >+ } >+ } >+ >+ /* >+ * Set the identifier of the comparator to use. >+ */ >+ public void setComparatorID(String value) { >+ ((MirrorApplication) application).setComparatorID(value); >+ } >+ >+ /* >+ * Set whether or not the application should be calling a comparator when mirroring. >+ */ >+ public void setCompare(boolean value) { >+ ((MirrorApplication) application).setCompare(value); >+ } >+ >+ /* >+ * Set whether or not we should ignore errors when running the mirror application. >+ */ >+ public void setIgnoreErrors(boolean value) { >+ ((MirrorApplication) application).setIgnoreErrors(value); >+ } >+ >+ /* >+ * Set whether or not the the artifacts are raw. >+ */ >+ public void setRaw(boolean value) { >+ ((MirrorApplication) application).setRaw(value); >+ } >+ >+ /* >+ * Set whether or not the mirror application should be run in verbose mode. >+ */ >+ public void setVerbose(boolean value) { >+ ((MirrorApplication) application).setVerbose(value); >+ } > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/plugin.xml,v >retrieving revision 1.4 >diff -u -r1.4 plugin.xml >--- plugin.xml 23 Feb 2009 16:55:10 -0000 1.4 >+++ plugin.xml 7 Mar 2009 00:48:16 -0000 >@@ -15,6 +15,18 @@ > library="lib/repository-tools-ant.jar" > name="p2.mirror"> > </antTask> >+ >+ <antTask >+ class="org.eclipse.equinox.p2.internal.repository.tools.tasks.ModifyRepositoryChildrenTask" >+ library="lib/repository-tools-ant.jar" >+ name="p2.modify.composite.repository.children"> >+ </antTask> >+ >+ <antTask >+ class="org.eclipse.equinox.p2.internal.repository.tools.tasks.CreateCompositeRepositoryTask" >+ library="lib/repository-tools-ant.jar" >+ name="p2.create.composite.repository"> >+ </antTask> > > <antTask > library="lib/repository-tools-ant.jar" >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ModifyRepoChildrenTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ModifyRepoChildrenTask.java >diff -N src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ModifyRepoChildrenTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ModifyRepoChildrenTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,58 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.p2.internal.repository.tools.tasks; >+ >+import java.util.Iterator; >+import org.apache.tools.ant.BuildException; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.p2.internal.repository.tools.ModifyCompositeApplication; >+ >+public class ModifyRepoChildrenTask extends AbstractRepositoryTask { >+ >+ public ModifyRepoChildrenTask() { >+ application = new ModifyCompositeApplication(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.apache.tools.ant.Task#execute() >+ */ >+ public void execute() throws BuildException { >+ try { >+ IStatus result = application.run(null); >+ if (result.matches(IStatus.ERROR)) { >+ throw new BuildException(TaskHelper.statusToString(result, null).toString()); >+ } >+ } catch (ProvisionException e) { >+ throw new BuildException(e); >+ } >+ } >+ >+ /* >+ * Add the listed repositories to the composite repository >+ */ >+ public void addConfiguredAdd(RepositoryList list) { >+ for (Iterator iter = list.getRepositoryList().iterator(); iter.hasNext();) { >+ DestinationRepository repo = (DestinationRepository) iter.next(); >+ ((ModifyCompositeApplication) application).addChild(repo.getDescriptor()); >+ } >+ } >+ >+ /* >+ * Remove the listed repositories from the composite repository >+ */ >+ public void addConfiguredRemove(RepositoryList list) { >+ for (Iterator iter = list.getRepositoryList().iterator(); iter.hasNext();) { >+ DestinationRepository repo = (DestinationRepository) iter.next(); >+ ((ModifyCompositeApplication) application).removeChild(repo.getDescriptor()); >+ } >+ } >+} >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeRepositoryTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeRepositoryTask.java >diff -N src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeRepositoryTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeRepositoryTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+package org.eclipse.equinox.p2.internal.repository.tools.tasks; >+ >+import java.util.Iterator; >+import org.apache.tools.ant.BuildException; >+import org.apache.tools.ant.Task; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.p2.internal.repository.tools.CreateCompositeRepositoryApplication; >+import org.eclipse.equinox.p2.internal.repository.tools.ModifyCompositeApplication; >+ >+public class CreateCompositeRepositoryTask extends Task { >+ CreateCompositeRepositoryApplication createApp; >+ ModifyCompositeApplication modifyApp; >+ >+ public CreateCompositeRepositoryTask() { >+ createApp = new CreateCompositeRepositoryApplication(); >+ modifyApp = new ModifyCompositeApplication(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.apache.tools.ant.Task#execute() >+ */ >+ public void execute() throws BuildException { >+ try { >+ IStatus result = createApp.run(null); >+ if (result.matches(IStatus.ERROR)) { >+ throw new BuildException(TaskHelper.statusToString(result, null).toString()); >+ } >+ result = modifyApp.run(null); >+ if (result.matches(IStatus.ERROR)) { >+ throw new BuildException(TaskHelper.statusToString(result, null).toString()); >+ } >+ } catch (ProvisionException e) { >+ throw new BuildException(e); >+ } >+ } >+ >+ /* >+ * Add a repository to create >+ */ >+ public DestinationRepository createRepository() { >+ DestinationRepository repo = new DestinationRepository(); >+ createApp.addRepository(repo.getDescriptor()); >+ modifyApp.addDestination(repo.getDescriptor()); >+ return repo; >+ } >+ >+ /* >+ * Set whether the task should fail if the repository already exists >+ */ >+ public void setFailOnExsists(boolean value) { >+ createApp.setFailOnExists(value); >+ } >+ >+ /* >+ * Add a list of child repositories to add to the newly created repository >+ */ >+ public void addConfiguredAdd(RepositoryList addList) { >+ for (Iterator iter = addList.getRepositoryList().iterator(); iter.hasNext();) { >+ DestinationRepository repo = (DestinationRepository) iter.next(); >+ modifyApp.addChild(repo.getDescriptor()); >+ } >+ } >+} >Index: src/org/eclipse/equinox/p2/internal/repository/tools/CreateCompositeRepositoryApplication.java >=================================================================== >RCS file: src/org/eclipse/equinox/p2/internal/repository/tools/CreateCompositeRepositoryApplication.java >diff -N src/org/eclipse/equinox/p2/internal/repository/tools/CreateCompositeRepositoryApplication.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/CreateCompositeRepositoryApplication.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,161 @@ >+package org.eclipse.equinox.p2.internal.repository.tools; >+ >+import java.net.URISyntaxException; >+import java.util.*; >+import org.apache.tools.ant.BuildException; >+import org.eclipse.core.runtime.*; >+import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository; >+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.artifact.repository.IArtifactRepository; >+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; >+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; >+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; >+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; >+ >+public class CreateCompositeRepositoryApplication { >+ >+ private String artifactName = "Composite Artifact Repository"; >+ private String metadataName = "Composite Artifact Repository"; >+ private List repositories = new ArrayList(); >+ private boolean failOnExists = false; >+ private IArtifactRepositoryManager artifactManager; >+ private IMetadataRepositoryManager metadataManager; >+ >+ public IStatus run(IProgressMonitor monitor) throws ProvisionException { >+ >+ MultiStatus status = new MultiStatus(Activator.ID, 0, "", null); //$NON-NLS-1$ >+ status.add(Status.OK_STATUS); >+ for (Iterator iterator = repositories.iterator(); iterator.hasNext();) >+ status.add(createRepository((RepositoryDescriptor) iterator.next())); >+ >+ return status; >+ } >+ >+ public void addRepository(RepositoryDescriptor repo) { >+ repositories.add(repo); >+ } >+ >+ public void setFailOnExists(boolean value) { >+ failOnExists = value; >+ } >+ >+ private IStatus createRepository(RepositoryDescriptor repo) throws ProvisionException { >+ if (repo.getKind() == IRepository.TYPE_ARTIFACT) >+ return createArtifactRepository(repo); >+ else if (repo.getKind() == IRepository.TYPE_METADATA) >+ return createMetadataRepository(repo); >+ else if (repo.getKind() == RepositoryDescriptor.TYPE_BOTH) { >+ MultiStatus status = new MultiStatus(Activator.ID, 0, "", null); //$NON-NLS-1$ >+ status.add(createArtifactRepository(repo)); >+ status.add(createMetadataRepository(repo)); >+ return status; >+ } else >+ throw new ProvisionException("Repository is of an unknown kind: " + repo.getRepoLocation()); >+ } >+ >+ private IStatus createArtifactRepository(RepositoryDescriptor repo) throws ProvisionException { >+ if (artifactManager == null) { >+ artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); >+ if (artifactManager == null) >+ throw new ProvisionException("Unable to obtain metadata repository manager."); >+ } >+ >+ boolean repoKnown = artifactManager.contains(repo.getRepoLocation()); >+ >+ // remove the repo first. >+ artifactManager.removeRepository(repo.getRepoLocation()); >+ >+ // first try and load to see if one already exists at that location. >+ // if we have an already existing repository at that location, then throw an error >+ // if the user told us to >+ try { >+ IArtifactRepository repository = artifactManager.loadRepository(repo.getRepoLocation(), null); >+ if (repository instanceof CompositeArtifactRepository) { >+ // Remove the repository if it wasn't previously known >+ if (!repoKnown) >+ artifactManager.removeRepository(repo.getRepoLocation()); >+ if (failOnExists) >+ throw new BuildException("Composite repository already exists at location: " + repo.getRepoLocation()); >+ return new Status(IStatus.INFO, Activator.ID, "Composite repository already exists at location: " + repo.getRepoLocation()); >+ } else { >+ // we have a non-composite repo at this location. that is ok because we can co-exist. >+ } >+ } catch (ProvisionException e) { >+ // re-throw the exception if we got anything other than "repo not found" >+ if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND) >+ throw e; >+ } >+ >+ IArtifactRepository source = null; >+ try { >+ if (repo.getFormat() != null) >+ source = artifactManager.loadRepository(URIUtil.fromString(repo.getFormat()), 0, null); >+ } catch (ProvisionException e) { >+ //Ignore. >+ } catch (URISyntaxException e) { >+ //Ignore >+ } >+ //This code assumes source has been successfully loaded before this point >+ //No existing repository; create a new repository at destinationLocation but with source's attributes. >+ // TODO for now create a Simple repo by default. >+ >+ IArtifactRepository result = null; >+ result = artifactManager.createRepository(repo.getRepoLocation(), repo.getName() != null ? repo.getName() : (source != null ? source.getName() : artifactName), IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, source != null ? source.getProperties() : null); >+ if (repo.isCompressed() && !result.getProperties().containsKey(IRepository.PROP_COMPRESSED)) >+ result.setProperty(IRepository.PROP_COMPRESSED, "true"); //$NON-NLS-1$ >+ >+ return Status.OK_STATUS; >+ } >+ >+ private IStatus createMetadataRepository(RepositoryDescriptor repo) throws ProvisionException { >+ if (metadataManager == null) { >+ metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); >+ if (metadataManager == null) >+ throw new ProvisionException("Unable to obtain metadata repository manager."); >+ } >+ >+ boolean repoKnown = metadataManager.contains(repo.getRepoLocation()); >+ // remove the repo first. >+ metadataManager.removeRepository(repo.getRepoLocation()); >+ >+ // first try and load to see if one already exists at that location. >+ // if we have an already existing repository at that location, then throw an error >+ // if the user told us to >+ try { >+ IMetadataRepository repository = metadataManager.loadRepository(repo.getRepoLocation(), null); >+ if (repository instanceof CompositeMetadataRepository) { >+ if (!repoKnown) >+ metadataManager.removeRepository(repo.getRepoLocation()); >+ if (failOnExists) >+ throw new BuildException("Composite repository already exists at location: " + repo.getRepoLocation()); >+ return new Status(IStatus.INFO, Activator.ID, "Composite repository already exists at location: " + repo.getRepoLocation()); >+ } else { >+ // we have a non-composite repo at this location. that is ok because we can co-exist. >+ } >+ } catch (ProvisionException e) { >+ // re-throw the exception if we got anything other than "repo not found" >+ if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND) >+ throw e; >+ } >+ >+ IMetadataRepository source = null; >+ try { >+ if (repo.getFormat() != null) >+ source = metadataManager.loadRepository(URIUtil.fromString(repo.getFormat()), 0, null); >+ } catch (ProvisionException e) { >+ //Ignore. >+ } catch (URISyntaxException e) { >+ //Ignore >+ } >+ //This code assumes source has been successfully loaded before this point >+ //No existing repository; create a new repository at destinationLocation but with source's attributes. >+ IMetadataRepository result = metadataManager.createRepository(repo.getRepoLocation(), repo.getName() != null ? repo.getName() : (source != null ? source.getName() : metadataName), IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, source != null ? source.getProperties() : null); >+ if (repo.isCompressed() && !result.getProperties().containsKey(IRepository.PROP_COMPRESSED)) >+ result.setProperty(IRepository.PROP_COMPRESSED, "true"); //$NON-NLS-1$ >+ >+ return Status.OK_STATUS; >+ } >+} >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java >diff -N src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryFileSet.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,22 @@ >+package org.eclipse.equinox.p2.internal.repository.tools.tasks; >+ >+import org.apache.tools.ant.types.FileSet; >+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; >+import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor; >+ >+public class RepositoryFileSet extends FileSet { >+ public final static int TYPE_BOTH = RepositoryDescriptor.TYPE_BOTH; >+ public final static int TYPE_ARTIFACT = IRepository.TYPE_ARTIFACT; >+ public final static int TYPE_METADATA = IRepository.TYPE_METADATA; >+ >+ int kind = TYPE_BOTH; >+ >+ public void setKind(String kind) { >+ // parse it >+ } >+ >+ public int getKind() { >+ return kind; >+ } >+ >+} >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java >diff -N src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/RepositoryList.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.p2.internal.repository.tools.tasks; >+ >+import java.util.ArrayList; >+import java.util.List; >+import org.apache.tools.ant.types.DataType; >+ >+public class RepositoryList extends DataType { >+ List repositories = new ArrayList(); >+ >+ public DestinationRepository createRepository() { >+ DestinationRepository repo = new DestinationRepository(); >+ repositories.add(repo); >+ return repo; >+ } >+ >+ public List getRepositoryList() { >+ return repositories; >+ } >+} >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SourceList.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SourceList.java >diff -N src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SourceList.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SourceList.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.p2.internal.repository.tools.tasks; >+ >+import java.util.ArrayList; >+import java.util.List; >+import org.apache.tools.ant.types.DataType; >+import org.apache.tools.ant.types.FileSet; >+ >+public class SourceList extends DataType { >+ List repositories = new ArrayList(); >+ List sourceFileSets = new ArrayList(); >+ >+ public DestinationRepository addRepository() { >+ DestinationRepository repo = new DestinationRepository(); >+ repositories.add(repo); >+ return repo; >+ } >+ >+ public void addFileSet(FileSet files) { >+ sourceFileSets.add(files); >+ } >+ >+ public List getRepositoryList() { >+ return repositories; >+ } >+ >+ public List getFileSetList() { >+ return sourceFileSets; >+ } >+} >Index: src/org/eclipse/equinox/p2/internal/repository/tools/ModifyCompositeApplication.java >=================================================================== >RCS file: src/org/eclipse/equinox/p2/internal/repository/tools/ModifyCompositeApplication.java >diff -N src/org/eclipse/equinox/p2/internal/repository/tools/ModifyCompositeApplication.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/ModifyCompositeApplication.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.p2.internal.repository.tools; >+ >+import java.util.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository; >+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.core.repository.IRepository; >+ >+public class ModifyCompositeApplication extends AbstractApplication { >+ private List childrenToAdd = new ArrayList(); >+ private List childrenToRemove = new ArrayList(); >+ >+ public IStatus run(IProgressMonitor monitor) throws ProvisionException { >+ try { >+ initializeRepos(new NullProgressMonitor()); >+ // load repository >+ CompositeMetadataRepository metadataRepo = (CompositeMetadataRepository) destinationMetadataRepository; >+ CompositeArtifactRepository artifactRepo = (CompositeArtifactRepository) destinationArtifactRepository; >+ >+ // Remove children from the Composite Repositories >+ for (Iterator iterator = childrenToRemove.iterator(); iterator.hasNext();) { >+ RepositoryDescriptor child = (RepositoryDescriptor) iterator.next(); >+ if (child.getKind() == IRepository.TYPE_ARTIFACT) >+ artifactRepo.removeChild(child.getRepoLocation()); >+ else if (child.getKind() == IRepository.TYPE_METADATA) >+ metadataRepo.removeChild(child.getRepoLocation()); >+ else if (child.getKind() == RepositoryDescriptor.TYPE_BOTH) { >+ artifactRepo.removeChild(child.getRepoLocation()); >+ metadataRepo.removeChild(child.getRepoLocation()); >+ } >+ } >+ >+ // Add children to the Composite Repositories >+ for (Iterator iterator = childrenToAdd.iterator(); iterator.hasNext();) { >+ RepositoryDescriptor child = (RepositoryDescriptor) iterator.next(); >+ if (child.getKind() == IRepository.TYPE_ARTIFACT) >+ artifactRepo.addChild(child.getRepoLocation()); >+ else if (child.getKind() == IRepository.TYPE_METADATA) >+ metadataRepo.addChild(child.getRepoLocation()); >+ else if (child.getKind() == RepositoryDescriptor.TYPE_BOTH) { >+ artifactRepo.addChild(child.getRepoLocation()); >+ metadataRepo.addChild(child.getRepoLocation()); >+ } >+ } >+ return null; >+ } finally { >+ finalizeRepositories(); >+ } >+ } >+ >+ public void addChild(RepositoryDescriptor child) { >+ childrenToAdd.add(child); >+ } >+ >+ public void removeChild(RepositoryDescriptor child) { >+ childrenToRemove.add(child); >+ } >+}
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 265550
:
126782
|
127893
|
127894
|
128031
|
131327
|
131450
|
131810
|
131811
|
132255
|
132298
|
132421
|
132422
|
132782
|
132783
|
132785
|
132929