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 132255 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 Tasks
Ant.patch (text/plain), 72.54 KB, created by
Matthew Piggott
on 2009-04-17 11:21:32 EDT
(
hide
)
Description:
Updated Tasks
Filename:
MIME Type:
Creator:
Matthew Piggott
Created:
2009-04-17 11:21:32 EDT
Size:
72.54 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.repository.tools >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/DestinationRepository.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/DestinationRepository.java,v >retrieving revision 1.1 >diff -u -r1.1 DestinationRepository.java >--- src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/DestinationRepository.java 17 Feb 2009 20:16:08 -0000 1.1 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/DestinationRepository.java 17 Apr 2009 15:22:07 -0000 >@@ -36,8 +36,12 @@ > } > } > >- public void setFormat(String format) { >- descriptor.setFormat(format); >+ public void setFormat(String formatLocation) { >+ try { >+ descriptor.setFormat(URIUtil.fromString(formatLocation)); >+ } catch (URISyntaxException e) { >+ throw new BuildException(e); >+ } > } > > public void setAppend(boolean appendMode) { >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 17 Apr 2009 15:22:07 -0000 >@@ -10,32 +10,42 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.internal.repository.tools.tasks; > >+import java.io.File; >+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.p2.artifact.repository.ant.AntMirrorLog; > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; > import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication; > > public class MirrorTask extends AbstractRepositoryTask { > >+ private File mirrorLog; // file to log mirror output to (optional) >+ > public MirrorTask() { > application = new MirrorApplication(); > } > > public void execute() throws BuildException { > try { >+ if (mirrorLog != null) >+ ((MirrorApplication) application).setLog(mirrorLog); >+ else >+ ((MirrorApplication) application).setLog(new AntMirrorLog(this)); > prepareSourceRepos(); > application.initializeRepos(null); > List ius = prepareIUs(); >- if (ius == null || ius.size() == 0) >- throw new BuildException("Need to specify one or more IUs to mirror."); > application.setSourceIUs(ius); > IStatus result = application.run(null); >- if (result.matches(IStatus.ERROR)) { >+ if (result.matches(IStatus.ERROR)) > throw new BuildException(TaskHelper.statusToString(result, null).toString()); >- } > } catch (ProvisionException e) { > throw new BuildException(e); >+ } catch (NoSuchMethodException e) { >+ // Should not occur >+ throw new BuildException(e); > } > } > >@@ -44,4 +54,68 @@ > ((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 the location of the comparator log >+ */ >+ public void setComparatorLog(String value) { >+ ((MirrorApplication) application).setComparatorLog(new File(value)); >+ } >+ >+ /* >+ * Set the location of the mirror log >+ */ >+ public void setLog(String value) { >+ mirrorLog = new File(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); >+ } >+ >+ public void setValidate(boolean value) { >+ ((MirrorApplication) application).setValidate(value); >+ } > } >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.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/SlicingOption.java,v >retrieving revision 1.4 >diff -u -r1.4 SlicingOption.java >--- src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java 14 Apr 2009 23:19:57 -0000 1.4 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/SlicingOption.java 17 Apr 2009 15:22:08 -0000 >@@ -13,7 +13,9 @@ > import java.util.*; > import org.apache.tools.ant.BuildException; > import org.apache.tools.ant.Task; >+import org.eclipse.equinox.p2.internal.repository.tools.Messages; > import org.eclipse.equinox.p2.internal.repository.tools.SlicingOptions; >+import org.eclipse.osgi.util.NLS; > > public class SlicingOption extends Task { > >@@ -51,7 +53,7 @@ > } > StringTokenizer tok = new StringTokenizer(platformFilter, ","); //$NON-NLS-1$ > if (tok.countTokens() != 3) >- throw new BuildException("Invalid platform filter format: " + platformFilter + "."); >+ throw new BuildException(NLS.bind(Messages.SlicingOption_invalid_platform, platformFilter)); > Dictionary filter = options.getFilter(); > if (filter == null) > filter = new Properties(); >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.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/ProcessRepoTask.java,v >retrieving revision 1.2 >diff -u -r1.2 ProcessRepoTask.java >--- src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java 3 Mar 2009 18:45:08 -0000 1.2 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ProcessRepoTask.java 17 Apr 2009 15:22:08 -0000 >@@ -21,8 +21,8 @@ > import org.eclipse.core.runtime.URIUtil; > import org.eclipse.equinox.internal.p2.jarprocessor.ant.JarProcessorTask; > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >-import org.eclipse.equinox.p2.internal.repository.tools.RecreateRepositoryApplication; >-import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor; >+import org.eclipse.equinox.p2.internal.repository.tools.*; >+import org.eclipse.osgi.util.NLS; > > public class ProcessRepoTask extends Task { > >@@ -64,7 +64,7 @@ > public void execute() throws BuildException { > File file = URIUtil.toFile(repository); > if (file == null || !file.exists()) { >- throw new BuildException("Repository must be local: " + repository.toString()); //$NON-NLS-1$ >+ throw new BuildException(NLS.bind(Messages.ProcessRepo_must_be_local, repository.toString())); > } > if (pack | repack | signing != null) { > if (jarProcessor == null) >@@ -113,7 +113,7 @@ > try { > this.repository = URIUtil.fromString(repository); > } catch (URISyntaxException e) { >- throw new IllegalArgumentException("Repository location (" + repository + ") must be a URL."); //$NON-NLS-1$ //$NON-NLS-2$ >+ throw new IllegalArgumentException(NLS.bind(Messages.ProcessRepo_location_not_url, repository)); > } > } > >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.5 >diff -u -r1.5 AbstractRepositoryTask.java >--- src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java 14 Apr 2009 21:19:08 -0000 1.5 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java 17 Apr 2009 15:22:07 -0000 >@@ -12,16 +12,18 @@ > > import java.io.File; > import java.net.URI; >-import java.net.URISyntaxException; > import java.util.*; > import org.apache.tools.ant.*; > import org.apache.tools.ant.types.FileSet; >-import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.URIUtil; >+import org.eclipse.equinox.internal.p2.artifact.repository.ant.AntMirrorLog; > import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; > import org.eclipse.equinox.internal.provisional.p2.query.Collector; > import org.eclipse.equinox.internal.provisional.p2.query.Query; > import org.eclipse.equinox.p2.internal.repository.tools.AbstractApplication; >+import org.eclipse.equinox.p2.internal.repository.tools.Messages; >+import org.eclipse.osgi.util.NLS; > > public abstract class AbstractRepositoryTask extends Task { > protected static final String ANT_PREFIX = "${"; //$NON-NLS-1$ >@@ -30,15 +32,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); > } >@@ -70,20 +63,15 @@ > * argument to specify both the artifact and metadata repositories. > */ > public void setDestination(String location) { >- DestinationRepository metadata = new DestinationRepository(); >- metadata.setLocation(URIUtil.toUnencodedString(new Path(location).toFile().toURI())); >- metadata.setKind("metadata"); //$NON-NLS-1$ >- application.addDestination(metadata.getDescriptor()); >- destinations.add(metadata); >- >- DestinationRepository artifact = new DestinationRepository(); >- artifact.setLocation(URIUtil.toUnencodedString(new Path(location).toFile().toURI())); >- metadata.setKind("artifact"); //$NON-NLS-1$ >- application.addDestination(artifact.getDescriptor()); >- destinations.add(artifact); >+ // TODO depreciate >+ DestinationRepository dest = new DestinationRepository(); >+ dest.setLocation(location); >+ destinations.add(dest); >+ application.addDestination(dest.getDescriptor()); > } > > public DestinationRepository createDestination() { >+ // TODO depreciate > DestinationRepository destination = new DestinationRepository(); > destinations.add(destination); > application.addDestination(destination.getDescriptor()); >@@ -91,17 +79,28 @@ > } > > /* >- * New FileSet subclass which adds an optional "location" attribute. >+ * Add a repository to mirror into > */ >- public class MyFileSet extends FileSet { >- String location; >+ public DestinationRepository createRepository() { >+ DestinationRepository destination = new DestinationRepository(); >+ destinations.add(destination); >+ application.addDestination(destination.getDescriptor()); >+ return destination; >+ } > >- public MyFileSet() { >- super(); >+ /* >+ * Add source repositories to mirror from >+ */ >+ public void addConfiguredSource(RepositoryList sourceList) { >+ for (Iterator iter = sourceList.getRepositoryList().iterator(); iter.hasNext();) { >+ DestinationRepository repo = (DestinationRepository) iter.next(); >+ application.addSource(repo.getDescriptor()); > } > >- public void setLocation(String value) { >- this.location = value; >+ for (Iterator iter = sourceList.getFileSetList().iterator(); iter.hasNext();) { >+ FileSet fileSet = (FileSet) iter.next(); >+ sourceRepos.add(fileSet); >+ // Added to the application later through prepareSourceRepos > } > } > >@@ -113,34 +112,34 @@ > 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(); >+ >+ if (fileset.getRepoLocation() != null) { >+ //TODO depreciate >+ if (!fileset.getRepoLocation().startsWith(ANT_PREFIX)) { >+ application.addSourceArtifactRepository(fileset.getRepoLocation()); >+ application.addSourceMetadataRepository(fileset.getRepoLocation()); >+ } >+ } else if (fileset.getDir() != 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$ >+ uri = URIUtil.toJarURI(uri, null); >+ } >+ if (fileset.isBoth()) { > application.addSourceArtifactRepository(uri); > application.addSourceMetadataRepository(uri); >- } >- } >- } else { >- if (!fileset.location.startsWith(ANT_PREFIX)) { >- application.addSourceArtifactRepository(fileset.location); >- application.addSourceMetadataRepository(fileset.location); >+ } else if (fileset.isArtifact()) >+ application.addSourceArtifactRepository(uri); >+ else if (fileset.isMetadata()) >+ application.addSourceMetadataRepository(uri); >+ else >+ throw new BuildException(NLS.bind(Messages.unknown_repository_type, uri)); > } > } > } >@@ -161,9 +160,17 @@ > repository.query(iuQuery, collector, null); > > if (iu.isRequired() && collector.isEmpty()) >- throw new BuildException("Unable to find: " + iu.toString()); //$NON-NLS-1$ >+ throw new BuildException(NLS.bind(Messages.AbstractRepositoryTask_missing_IU, iu.toString())); > result.addAll(collector.toCollection()); > } > return result; > } >+ >+ protected void log(IStatus status) { >+ try { >+ new AntMirrorLog(this).log(status); >+ } catch (NoSuchMethodException e) { >+ // Shouldn't occur >+ } >+ } > } >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 17 Apr 2009 15:22:07 -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/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.8 >diff -u -r1.8 AbstractApplication.java >--- src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java 13 Apr 2009 19:34:19 -0000 1.8 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/AbstractApplication.java 17 Apr 2009 15:22:07 -0000 >@@ -13,7 +13,8 @@ > import java.net.URI; > import java.net.URISyntaxException; > import java.util.*; >-import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository; > import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository; > import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper; >@@ -22,11 +23,13 @@ > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; > import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; > import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; >-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager; >+import org.eclipse.equinox.internal.provisional.p2.repository.*; >+import org.eclipse.osgi.util.NLS; > > public abstract class AbstractApplication { >+ protected boolean removeUnknownRepositories = true; > >+ protected List sourceRepositories = new ArrayList(); > protected List sourceArtifactRepositories = new ArrayList(); > protected List sourceMetadataRepositories = new ArrayList(); > protected List artifactReposToRemove = new ArrayList(); >@@ -40,6 +43,9 @@ > private CompositeMetadataRepository compositeMetadataRepository = null; > private CompositeArtifactRepository compositeArtifactRepository = null; > >+ /* >+ * Add a source metadata repository >+ */ > public void addSourceMetadataRepository(String location) { > URI uri = Activator.getURI(location); > if (uri != null) >@@ -71,15 +77,30 @@ > } > > protected void finalizeRepositories() throws ProvisionException { >- IArtifactRepositoryManager artifactRepositoryManager = Activator.getArtifactRepositoryManager(); >- for (Iterator iter = artifactReposToRemove.iterator(); iter.hasNext();) >- artifactRepositoryManager.removeRepository((URI) iter.next()); >- IMetadataRepositoryManager metadataRepositoryManager = Activator.getMetadataRepositoryManager(); >- for (Iterator iter = metadataReposToRemove.iterator(); iter.hasNext();) >- metadataRepositoryManager.removeRepository((URI) iter.next()); >+ if (removeUnknownRepositories) { >+ IArtifactRepositoryManager artifactRepositoryManager = Activator.getArtifactRepositoryManager(); >+ for (Iterator iter = artifactReposToRemove.iterator(); iter.hasNext();) >+ artifactRepositoryManager.removeRepository((URI) iter.next()); >+ IMetadataRepositoryManager metadataRepositoryManager = Activator.getMetadataRepositoryManager(); >+ for (Iterator iter = metadataReposToRemove.iterator(); iter.hasNext();) >+ metadataRepositoryManager.removeRepository((URI) iter.next()); >+ } > } > > public void initializeRepos(IProgressMonitor progress) throws ProvisionException { >+ for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ if (repo.isBoth()) { >+ sourceArtifactRepositories.add(repo.getRepoLocation()); >+ sourceMetadataRepositories.add(repo.getRepoLocation()); >+ } else if (repo.isArtifact()) >+ sourceArtifactRepositories.add(repo.getRepoLocation()); >+ else if (repo.isMetadata()) >+ sourceMetadataRepositories.add(repo.getRepoLocation()); >+ else >+ throw new ProvisionException(NLS.bind(Messages.unknown_repository_type, repo.getRepoLocation())); >+ } >+ > IArtifactRepositoryManager artifactRepositoryManager = Activator.getArtifactRepositoryManager(); > if (sourceArtifactRepositories != null && !sourceArtifactRepositories.isEmpty()) { > for (Iterator iter = sourceArtifactRepositories.iterator(); iter.hasNext();) { >@@ -101,17 +122,28 @@ > } > > 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 = ((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); >+ RepositoryDescriptor artifactRepoDescriptor = null; >+ RepositoryDescriptor metadataRepoDescriptor = null; >+ >+ Iterator iter = destinationRepos.iterator(); >+ while (iter.hasNext() && (artifactRepoDescriptor == null || metadataRepoDescriptor == null)) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ if (repo.isArtifact() && artifactRepoDescriptor == null) >+ artifactRepoDescriptor = repo; >+ if (repo.isMetadata() && metadataRepoDescriptor == null) >+ metadataRepoDescriptor = repo; >+ } >+ >+ if (artifactRepoDescriptor != null) >+ destinationArtifactRepository = initializeDestination(artifactRepoDescriptor, artifactRepositoryManager); >+ if (metadataRepoDescriptor != null) >+ destinationMetadataRepository = initializeDestination(metadataRepoDescriptor, metadataRepositoryManager); >+ >+ if (destinationMetadataRepository == null && destinationArtifactRepository == null) >+ throw new ProvisionException(Messages.AbstractApplication_no_valid_destinations); > } > > private IMetadataRepository initializeDestination(RepositoryDescriptor toInit, IMetadataRepositoryManager mgr) throws ProvisionException { >@@ -119,13 +151,8 @@ > 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()) { >- if (toInit.getName() != null) >- repository.setName(toInit.getName()); >- if (!toInit.isAppend()) >- repository.removeAll(); >+ if (initDestinationRepository(repository, toInit)) > return repository; >- } > } catch (ProvisionException e) { > //fall through and create a new repository below > } >@@ -133,11 +160,9 @@ > IMetadataRepository source = null; > try { > if (toInit.getFormat() != null) >- source = mgr.loadRepository(URIUtil.fromString(toInit.getFormat()), 0, null); >+ source = mgr.loadRepository(toInit.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. >@@ -152,24 +177,17 @@ > 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()) { >- if (toInit.getName() != null) >- repository.setName(toInit.getName()); >- if (!toInit.isAppend()) >- repository.removeAll(); >+ if (initDestinationRepository(repository, toInit)) > return repository; >- } > } catch (ProvisionException e) { > //fall through and create a new repository below > } > IArtifactRepository source = null; > try { > if (toInit.getFormat() != null) >- source = mgr.loadRepository(URIUtil.fromString(toInit.getFormat()), 0, null); >+ source = mgr.loadRepository(toInit.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. >@@ -180,6 +198,21 @@ > return (IArtifactRepository) RepositoryHelper.validDestinationRepository(result); > } > >+ private boolean initDestinationRepository(IRepository repository, RepositoryDescriptor descriptor) { >+ if (repository != null && repository.isModifiable()) { >+ if (descriptor.getName() != null) >+ repository.setName(descriptor.getName()); >+ if (repository instanceof ICompositeRepository && !descriptor.isAppend()) >+ ((ICompositeRepository) repository).removeAllChildren(); >+ else if (repository instanceof IMetadataRepository && !descriptor.isAppend()) >+ ((IMetadataRepository) repository).removeAll(); >+ else if (repository instanceof IArtifactRepository && !descriptor.isAppend()) >+ ((IArtifactRepository) repository).removeAll(); >+ return true; >+ } >+ return false; >+ } >+ > public IMetadataRepository getCompositeMetadataRepository() { > if (compositeMetadataRepository == null) { > try { >@@ -197,7 +230,7 @@ > public IArtifactRepository getCompositeArtifactRepository() { > if (compositeArtifactRepository == null) { > try { >- compositeArtifactRepository = new CompositeArtifactRepository(new URI("memory:/composite"), "parent metadata repo", null);//$NON-NLS-1$ //$NON-NLS-2$ >+ compositeArtifactRepository = new CompositeArtifactRepository(new URI("memory:/composite"), "parent artifact repo", null);//$NON-NLS-1$ //$NON-NLS-2$ > } catch (URISyntaxException e) { > //Can't happen > } >@@ -213,4 +246,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/org/eclipse/equinox/p2/internal/repository/tools/Activator.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Activator.java,v >retrieving revision 1.3 >diff -u -r1.3 Activator.java >--- src/org/eclipse/equinox/p2/internal/repository/tools/Activator.java 18 Mar 2009 14:31:53 -0000 1.3 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/Activator.java 17 Apr 2009 15:22:07 -0000 >@@ -19,6 +19,7 @@ > import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; > import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; > import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; >+import org.eclipse.osgi.util.NLS; > import org.osgi.framework.*; > import org.osgi.service.packageadmin.PackageAdmin; > >@@ -43,7 +44,7 @@ > // TODO needed to do this to ensure the profile registry was registered > Bundle bundle = getBundle("org.eclipse.equinox.p2.exemplarysetup"); //$NON-NLS-1$ > if (bundle == null) >- throw new ProvisionException("Unable to start exemplarysetup bundle."); >+ throw new ProvisionException(Messages.unable_to_start_exemplarysetup); > bundle.start(Bundle.START_TRANSIENT); > } > >@@ -64,7 +65,7 @@ > try { > return URIUtil.fromString(spec); > } catch (URISyntaxException e) { >- LogHelper.log(new Status(IStatus.WARNING, ID, "Unable to process as URI: " + spec, e)); >+ LogHelper.log(new Status(IStatus.WARNING, ID, NLS.bind(Messages.unable_to_process_uri, spec), e)); > } > return null; > } >@@ -75,7 +76,7 @@ > public static IArtifactRepositoryManager getArtifactRepositoryManager() throws ProvisionException { > IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(getBundleContext(), IArtifactRepositoryManager.class.getName()); > if (manager == null) >- throw new ProvisionException("Unable to acquire artifact repository manager service."); >+ throw new ProvisionException(Messages.no_artifactRepo_manager); > return manager; > } > >@@ -85,7 +86,7 @@ > static IProfileRegistry getProfileRegistry() throws ProvisionException { > IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(getBundleContext(), IProfileRegistry.class.getName()); > if (registry == null) >- throw new ProvisionException("Unable to acquire profile registry service."); >+ throw new ProvisionException(Messages.no_profile_registry); > return registry; > } > >@@ -95,7 +96,7 @@ > public static synchronized Bundle getBundle(String symbolicName) throws ProvisionException { > PackageAdmin packageAdmin = (PackageAdmin) ServiceHelper.getService(getBundleContext(), PackageAdmin.class.getName()); > if (packageAdmin == null) >- throw new ProvisionException("Unable to acquire package admin service."); >+ throw new ProvisionException(Messages.no_package_admin); > Bundle[] bundles = packageAdmin.getBundles(symbolicName, null); > if (bundles == null) > return null; >@@ -113,7 +114,7 @@ > public static IMetadataRepositoryManager getMetadataRepositoryManager() throws ProvisionException { > IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(getBundleContext(), IMetadataRepositoryManager.class.getName()); > if (manager == null) >- throw new ProvisionException("Unable to acquire metadata repository manager service."); >+ throw new ProvisionException(Messages.no_metadataRepo_manager); > return manager; > } > } >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 17 Apr 2009 15:22:07 -0000 >@@ -10,45 +10,75 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.internal.repository.tools; > >+import java.io.File; >+import java.net.URI; > import java.util.ArrayList; > import java.util.Iterator; > import org.eclipse.core.runtime.*; > import org.eclipse.equinox.app.IApplication; > import org.eclipse.equinox.app.IApplicationContext; >-import org.eclipse.equinox.internal.p2.artifact.mirror.Mirroring; >+import org.eclipse.equinox.internal.p2.artifact.mirror.*; >+import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; > 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.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; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager; > > public class MirrorApplication extends AbstractApplication { >+ private static final String LOG_ROOT = "p2.mirror"; //$NON-NLS-1$ >+ > protected SlicingOptions slicingOptions = new SlicingOptions(); > >+ private URI baseline; >+ private String comparatorID; >+ private boolean compare = false; >+ private boolean failOnError = true; >+ private boolean raw = true; >+ private boolean verbose = false; >+ private boolean validate = false; >+ >+ private File mirrorLogFile; // file to log mirror output to (optional) >+ private File comparatorLogFile; // file to comparator output to (optional) >+ private IArtifactMirrorLog mirrorLog; >+ private IArtifactMirrorLog comparatorLog; >+ > public Object start(IApplicationContext context) throws Exception { > run(null); > return IApplication.EXIT_OK; > } > > public IStatus run(IProgressMonitor monitor) throws ProvisionException { >+ IStatus mirrorStatus = Status.OK_STATUS; > try { > validate(); > initializeRepos(new NullProgressMonitor()); >+ initializeIUs(); > IQueryable slice = slice(new NullProgressMonitor()); >- IStatus mirrorStatus = mirrorArtifacts(slice, new NullProgressMonitor()); >- if (mirrorStatus.getSeverity() == IStatus.ERROR) { >- return mirrorStatus; >+ if (destinationArtifactRepository != null) { >+ initializeLogs(); >+ 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(); >+ finalizeLogs(); > } >- return Status.OK_STATUS; >+ if (mirrorStatus.isOK()) >+ return Status.OK_STATUS; >+ return mirrorStatus; > } > >- 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 +88,37 @@ > keys.add(iuKeys[i]); > } > } >- Mirroring mirror = new Mirroring(getCompositeArtifactRepository(), destinationArtifactRepository, true); >- mirror.setArtifactKeys((IArtifactKey[]) keys.toArray(new IArtifactKey[keys.size()])); >- return mirror.run(true, false); >+ Mirroring mirror = new Mirroring(getCompositeArtifactRepository(), destinationArtifactRepository, raw); >+ >+ mirror.setCompare(compare); >+ mirror.setComparatorId(comparatorID); >+ mirror.setBaseline(initializeBaseline()); >+ mirror.setValidate(validate); >+ >+ // If IUs have been specified then only they should be mirrored, otherwise mirror everything. >+ if (keys.size() > 0) >+ mirror.setArtifactKeys((IArtifactKey[]) keys.toArray(new IArtifactKey[keys.size()])); >+ >+ if (comparatorLog != null) >+ mirror.setComparatorLog(comparatorLog); >+ >+ IStatus result = mirror.run(failOnError, verbose); >+ >+ if (mirrorLog != null) >+ mirrorLog.log(result); >+ else >+ LogHelper.log(result); >+ return result; >+ } >+ >+ 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) { >@@ -75,11 +133,60 @@ > * to add more if they wish) > */ > 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 (sourceMetadataRepositories.isEmpty() && sourceArtifactRepositories.isEmpty() && sourceRepositories.isEmpty()) >+ throw new ProvisionException(Messages.MirrorApplication_set_source_repositories); >+ } >+ >+ /* >+ * If no IUs have been specified we want to mirror them all >+ */ >+ private void initializeIUs() 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 && destinationMetadataRepository != null) { >+ throw new ProvisionException(Messages.MirrorApplication_no_IUs); >+ } >+ } else { >+ //TODO Check that the IU is in repo >+ } >+ } >+ >+ /* >+ * Initialize logs, if applicable >+ */ >+ private void initializeLogs() { >+ if (compare && comparatorLogFile != null) >+ comparatorLog = getLog(comparatorLogFile, comparatorID); >+ if (mirrorLog == null && mirrorLogFile != null) >+ mirrorLog = getLog(mirrorLogFile, LOG_ROOT); >+ } >+ >+ /* >+ * Finalize logs, if applicable >+ */ >+ private void finalizeLogs() { >+ if (comparatorLog != null) >+ comparatorLog.close(); >+ if (mirrorLog != null) >+ mirrorLog.close(); >+ } >+ >+ /* >+ * Get the log for a location >+ */ >+ private IArtifactMirrorLog getLog(File location, String root) { >+ String absolutePath = location.getAbsolutePath(); >+ if (absolutePath.toLowerCase().endsWith(".xml")) //$NON-NLS-1$ >+ return new XMLMirrorLog(absolutePath, 0, root); >+ return new FileMirrorLog(absolutePath, 0, root); > } > > private IQueryable slice(IProgressMonitor monitor) { >@@ -92,4 +199,76 @@ > 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; >+ } >+ >+ /* >+ * Set the location of the log for comparator output >+ */ >+ public void setComparatorLog(File comparatorLog) { >+ this.comparatorLogFile = comparatorLog; >+ } >+ >+ /* >+ * Set the location of the log for mirroring. >+ */ >+ public void setLog(File mirrorLog) { >+ this.mirrorLogFile = mirrorLog; >+ } >+ >+ /* >+ * Set the ArtifactMirror log >+ */ >+ public void setLog(IArtifactMirrorLog log) { >+ mirrorLog = log; >+ } >+ >+ /* >+ * Set if the artifact mirror should be validated >+ */ >+ public void setValidate(boolean value) { >+ validate = 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.3 >diff -u -r1.3 RepositoryDescriptor.java >--- src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java 30 Mar 2009 01:49:17 -0000 1.3 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/RepositoryDescriptor.java 17 Apr 2009 15:22:07 -0000 >@@ -10,18 +10,23 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.internal.repository.tools; > >-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >- > import java.net.URI; >+import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >+import org.eclipse.osgi.util.NLS; > > public class RepositoryDescriptor { > >+ public static final int TYPE_BOTH = -1; >+ public static final String KIND_ARTIFACT = "A"; //$NON-NLS-1$ >+ public static final String KIND_METADATA = "M"; //$NON-NLS-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 URI format = null; >+ private int kind = TYPE_BOTH; > > public void setCompressed(boolean compress) { > compressed = compress; >@@ -32,11 +37,11 @@ > } > > public void setLocation(URI repoLocation) { >- location = repoLocation; >+ location = RepositoryHelper.localRepoURIHelper(repoLocation); > } > >- public void setFormat(String format) { >- this.format = format; >+ public void setFormat(URI format) { >+ this.format = RepositoryHelper.localRepoURIHelper(format); > } > > public void setAppend(boolean appendMode) { >@@ -59,7 +64,7 @@ > return location; > } > >- public String getFormat() { >+ public URI getFormat() { > return format; > } > >@@ -67,11 +72,38 @@ > return kind; > } > >+ public boolean isBoth() { >+ return kind == TYPE_BOTH; >+ } >+ >+ public boolean isArtifact() { >+ return kind == TYPE_BOTH || kind == IRepository.TYPE_ARTIFACT; >+ } >+ >+ public boolean isMetadata() { >+ return kind == TYPE_BOTH || kind == IRepository.TYPE_METADATA; >+ } >+ > public void setKind(String repoKind) { >- if (repoKind.startsWith("m") || repoKind.startsWith("M")) //$NON-NLS-1$//$NON-NLS-2$ >- kind = IRepository.TYPE_METADATA; >+ kind = determineKind(repoKind); >+ } > >- if (repoKind.startsWith("a") || repoKind.startsWith("A")) //$NON-NLS-1$//$NON-NLS-2$ >- kind = IRepository.TYPE_ARTIFACT; >+ /* >+ * Determine the repository type >+ */ >+ public static int determineKind(String repoKind) { >+ if (kindMatches(repoKind, KIND_METADATA)) >+ return IRepository.TYPE_METADATA; >+ else if (kindMatches(repoKind, KIND_ARTIFACT)) >+ return IRepository.TYPE_ARTIFACT; >+ >+ throw new IllegalArgumentException(NLS.bind(Messages.unknown_repository_type, repoKind)); >+ } >+ >+ /* >+ * Determine if the repository kind matches the identifier kind >+ */ >+ public static boolean kindMatches(String repoKind, String kindIdentifier) { >+ return repoKind.startsWith(kindIdentifier) || repoKind.startsWith(kindIdentifier.toLowerCase()); > } > } >Index: src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java,v >retrieving revision 1.11 >diff -u -r1.11 Repo2Runnable.java >--- src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java 14 Apr 2009 21:19:08 -0000 1.11 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java 17 Apr 2009 15:22:07 -0000 >@@ -247,14 +247,9 @@ > } > > if (option.equalsIgnoreCase("-destination")) { //$NON-NLS-1$ >- RepositoryDescriptor artifact = new RepositoryDescriptor(); >- artifact.setLocation(URIUtil.fromString(arg)); >- artifact.setKind("A"); //$NON-NLS-1$ >- addDestination(artifact); >- RepositoryDescriptor metadata = new RepositoryDescriptor(); >- metadata.setLocation(URIUtil.fromString(arg)); >- metadata.setKind("M"); //$NON-NLS-1$ >- addDestination(metadata); >+ RepositoryDescriptor destination = new RepositoryDescriptor(); >+ destination.setLocation(URIUtil.fromString(arg)); >+ addDestination(destination); > } > } > } >Index: src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java,v >retrieving revision 1.3 >diff -u -r1.3 Messages.java >--- src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java 14 Apr 2009 21:19:08 -0000 1.3 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/Messages.java 17 Apr 2009 15:22:07 -0000 >@@ -21,6 +21,38 @@ > public static String exception_needIUsOrNonEmptyRepo; > public static String exception_needDestinationRepo; > >+ public static String AbstractApplication_no_valid_destinations; >+ >+ public static String AbstractRepositoryTask_missing_IU; >+ >+ public static String CompositeRepository_composite_repository_exists; >+ public static String CompositeRepository_create_colocated_composite_repos; >+ public static String CompositeRepository_creating_composite_repositories; >+ public static String CompositeRepository_default_artifactRepo_name; >+ public static String CompositeRepository_default_metadataRepo_name; >+ >+ public static String no_valid_IUs; >+ public static String no_artifactRepo_manager; >+ public static String no_metadataRepo_manager; >+ public static String no_package_admin; >+ public static String no_profile_registry; >+ public static String unable_to_process_uri; >+ public static String unable_to_start_exemplarysetup; >+ public static String unknown_repository_type; >+ >+ public static String MirrorApplication_no_IUs; >+ public static String MirrorApplication_set_source_repositories; >+ >+ public static String ProcessRepo_location_not_url; >+ public static String ProcessRepo_must_be_local; >+ >+ public static String Repo2Runnable_no_destination_repository; >+ public static String Repo2Runnable_no_engine; >+ >+ public static String Repo2RunnableTask_error_transforming_repository; >+ >+ public static String SlicingOption_invalid_platform; >+ > static { > // initialize resource bundles > NLS.initializeMessages(BUNDLE_NAME, Messages.class); >Index: src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties,v >retrieving revision 1.3 >diff -u -r1.3 messages.properties >--- src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties 14 Apr 2009 21:19:08 -0000 1.3 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/messages.properties 17 Apr 2009 15:22:07 -0000 >@@ -8,6 +8,32 @@ > # Contributors: > # IBM Corporation - initial API and implementation > ############################################################################### >+AbstractApplication_no_valid_destinations=Unable to locate a valid destination repository. >+AbstractRepositoryTask_missing_IU=Unable to find IU: >+ >+CompositeRepository_default_metadataRepo_name=Composite Metadata Repository >+CompositeRepository_default_artifactRepo_name=Composite Artifact Repository >+CompositeRepository_create_colocated_composite_repos=Creating co-located composite repositories. >+CompositeRepository_composite_repository_exists=Composite repository already exists at location: {0} >+CompositeRepository_creating_composite_repositories=Creating Composite Repositories >+CompositeRepository_default_artifactRepo_name=Composite Artifact Repository >+CompositeRepository_default_metadataRepo_name=Composite Artifact Repository >+ >+no_valid_IUs=Need to specify either a non-empty source metadata repository or a valid list of IUs. >+no_artifactRepo_manager=Unable to acquire artifact repository manager service. >+no_metadataRepo_manager=Unable to acquire metadata repository manager service. >+no_package_admin=Unable to acquire package admin service. >+no_profile_registry=Unable to acquire profile registry service. >+unable_to_process_uri=Unable to process as URI: {0} >+unable_to_start_exemplarysetup=Unable to start exemplarysetup bundle. >+unknown_repository_type=Repository is of an unknown type: {0} >+ >+MirrorApplication_no_IUs=No IUs specified and no IUs obtained from metadata repositories. >+MirrorApplication_set_source_repositories=Need to set the source repository location(s). >+ProcessRepo_location_not_url=Repository location {0} must be a URL. >+ProcessRepo_must_be_local=Repository must be local: {0} >+ >+SlicingOption_invalid_platform=Invalid platform filter format: {0}. > exception_destinationNotModifiable = The destination repository must be modifiable: {0}. > > exception_unableToRemoveRepo=Unable to remove artifact repository file: {0}. >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.repository.tools/META-INF/MANIFEST.MF,v >retrieving revision 1.11 >diff -u -r1.11 MANIFEST.MF >--- META-INF/MANIFEST.MF 14 Apr 2009 21:19:08 -0000 1.11 >+++ META-INF/MANIFEST.MF 17 Apr 2009 15:22:07 -0000 >@@ -12,6 +12,7 @@ > org.eclipse.equinox.app;version="1.0.0", > org.eclipse.equinox.internal.p2.artifact.mirror, > org.eclipse.equinox.internal.p2.artifact.repository, >+ org.eclipse.equinox.internal.p2.artifact.repository.ant, > org.eclipse.equinox.internal.p2.artifact.repository.simple, > org.eclipse.equinox.internal.p2.core.helpers, > org.eclipse.equinox.internal.p2.director, >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ModifyRepositoryChildrenTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ModifyRepositoryChildrenTask.java >diff -N src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ModifyRepositoryChildrenTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ModifyRepositoryChildrenTask.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.ModifyCompositeRepositoryApplication; >+ >+public class ModifyRepositoryChildrenTask extends AbstractRepositoryTask { >+ >+ public ModifyRepositoryChildrenTask() { >+ application = new ModifyCompositeRepositoryApplication(); >+ } >+ >+ /* (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(); >+ ((ModifyCompositeRepositoryApplication) 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(); >+ ((ModifyCompositeRepositoryApplication) application).removeChild(repo.getDescriptor()); >+ } >+ } >+} >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,42 @@ >+/******************************************************************************* >+ * 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; >+ >+public class RepositoryList extends RepositoryFileSet { >+ // TODO this class should extend DataType, currently RepoFileSet to support <source location="xxx" /> >+ List repositories = new ArrayList(); >+ List sourceFileSets = new ArrayList(); >+ >+ public DestinationRepository createRepository() { >+ DestinationRepository repo = new DestinationRepository(); >+ repositories.add(repo); >+ return repo; >+ } >+ >+ public RepositoryFileSet createFileSet() { >+ RepositoryFileSet fileSet = new RepositoryFileSet(); >+ sourceFileSets.add(fileSet); >+ return fileSet; >+ } >+ >+ public List getRepositoryList() { >+ return repositories; >+ } >+ >+ public List getFileSetList() { >+ //TODO this should eventually be removed >+ sourceFileSets.add(this); >+ return sourceFileSets; >+ } >+} >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,53 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.p2.internal.repository.tools.tasks; >+ >+import org.apache.tools.ant.types.FileSet; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >+import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor; >+ >+public class RepositoryFileSet extends FileSet { >+ public final static int TYPE_ARTIFACT = IRepository.TYPE_ARTIFACT; >+ public final static int TYPE_METADATA = IRepository.TYPE_METADATA; >+ >+ private int kind = RepositoryDescriptor.TYPE_BOTH; >+ protected String myLocation = null; >+ >+ public void setKind(String repoKind) { >+ kind = RepositoryDescriptor.determineKind(repoKind); >+ } >+ >+ public int getKind() { >+ return kind; >+ } >+ >+ public boolean isBoth() { >+ return kind == RepositoryDescriptor.TYPE_BOTH; >+ } >+ >+ public boolean isArtifact() { >+ return kind == RepositoryDescriptor.TYPE_BOTH || kind == IRepository.TYPE_ARTIFACT; >+ } >+ >+ public boolean isMetadata() { >+ return kind == RepositoryDescriptor.TYPE_BOTH || kind == IRepository.TYPE_METADATA; >+ } >+ >+ public void setLocation(String value) { >+ // TODO depreciate >+ myLocation = value; >+ } >+ >+ public String getRepoLocation() { >+ // TODO depreciate >+ return myLocation; >+ } >+} >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,166 @@ >+/******************************************************************************* >+ * 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.apache.tools.ant.BuildException; >+import org.eclipse.core.runtime.*; >+import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper; >+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.metadata.repository.IMetadataRepository; >+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; >+import org.eclipse.equinox.internal.provisional.p2.repository.ICompositeRepository; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >+import org.eclipse.osgi.util.NLS; >+ >+public class CreateCompositeRepositoryApplication { >+ >+ private List repositories = new ArrayList(); >+ private boolean failOnExists = false; >+ private IArtifactRepositoryManager artifactManager; >+ private IMetadataRepositoryManager metadataManager; >+ >+ public IStatus run(IProgressMonitor monitor) throws ProvisionException { >+ artifactManager = Activator.getArtifactRepositoryManager(); >+ metadataManager = Activator.getMetadataRepositoryManager(); >+ >+ MultiStatus status = new MultiStatus(Activator.ID, 0, Messages.CompositeRepository_creating_composite_repositories, null); >+ 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 { >+ try { >+ if (repo.isBoth()) { >+ MultiStatus status = new MultiStatus(Activator.ID, 0, Messages.CompositeRepository_create_colocated_composite_repos, null); >+ status.add(createArtifactRepository(repo)); >+ status.add(createMetadataRepository(repo)); >+ return status; >+ } else if (repo.isArtifact()) >+ return createArtifactRepository(repo); >+ else if (repo.isMetadata()) >+ return createMetadataRepository(repo); >+ else >+ throw new ProvisionException(Messages.unknown_repository_type + repo.getRepoLocation()); >+ } catch (IllegalStateException e) { >+ throw new ProvisionException(e.getMessage(), e); >+ } >+ } >+ >+ private IStatus createArtifactRepository(RepositoryDescriptor repo) throws ProvisionException { >+ // remove the repo first. >+ artifactManager.removeRepository(repo.getRepoLocation()); >+ >+ // first try and load to see if one already exists at that location. >+ try { >+ IArtifactRepository repository = artifactManager.loadRepository(repo.getRepoLocation(), null); >+ if (!validRepositoryLocation(repository)) >+ return new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.CompositeRepository_composite_repository_exists, repo.getRepoLocation())); >+ } 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(repo.getFormat(), 0, null); >+ } catch (ProvisionException e) { >+ //Ignore. >+ } >+ //This code assumes source has been successfully loaded before this point >+ try { >+ //No existing repository; create a new repository at destinationLocation but with source's attributes. >+ IArtifactRepository result = null; >+ result = artifactManager.createRepository(repo.getRepoLocation(), repo.getName() != null ? repo.getName() : (source != null ? source.getName() : Messages.CompositeRepository_default_artifactRepo_name), IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, source != null ? source.getProperties() : null); >+ initRepository(result, repo); >+ } catch (IllegalStateException e) { >+ artifactManager.removeRepository(repo.getRepoLocation()); >+ throw e; >+ } >+ return Status.OK_STATUS; >+ } >+ >+ private IStatus createMetadataRepository(RepositoryDescriptor repo) throws ProvisionException { >+ // remove the repo first. >+ metadataManager.removeRepository(repo.getRepoLocation()); >+ >+ // first try and load to see if one already exists at that location. >+ try { >+ IMetadataRepository repository = metadataManager.loadRepository(repo.getRepoLocation(), null); >+ if (!validRepositoryLocation(repository)) >+ return new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.CompositeRepository_composite_repository_exists, repo.getRepoLocation())); >+ } 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(repo.getFormat(), 0, null); >+ } catch (ProvisionException e) { >+ //Ignore >+ } >+ //This code assumes source has been successfully loaded before this point >+ try { >+ //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() : Messages.CompositeRepository_default_metadataRepo_name), IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, source != null ? source.getProperties() : null); >+ initRepository(result, repo); >+ } catch (IllegalStateException e) { >+ metadataManager.removeRepository(repo.getRepoLocation()); >+ throw e; >+ } >+ >+ return Status.OK_STATUS; >+ } >+ >+ /* >+ * Determine if the repository is valid for this operation >+ */ >+ private boolean validRepositoryLocation(IRepository repository) { >+ if (repository instanceof ICompositeRepository) { >+ // if we have an already existing repository at that location, then throw an error >+ // if the user told us to >+ if (failOnExists) >+ throw new BuildException(NLS.bind(Messages.CompositeRepository_composite_repository_exists, repository.getLocation())); >+ RepositoryHelper.validDestinationRepository(repository); >+ return false; >+ } >+ // we have a non-composite repo at this location. that is ok because we can co-exist. >+ return true; >+ } >+ >+ /* >+ * Initialize a new repository >+ */ >+ private void initRepository(IRepository repository, RepositoryDescriptor desc) { >+ RepositoryHelper.validDestinationRepository(repository); >+ if (desc.isCompressed() && !repository.getProperties().containsKey(IRepository.PROP_COMPRESSED)) >+ repository.setProperty(IRepository.PROP_COMPRESSED, String.valueOf(true)); >+ } >+ >+} >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,79 @@ >+/******************************************************************************* >+ * 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.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.ModifyCompositeRepositoryApplication; >+ >+public class CreateCompositeRepositoryTask extends Task { >+ CreateCompositeRepositoryApplication createApp; >+ ModifyCompositeRepositoryApplication modifyApp; >+ boolean add = false; >+ >+ public CreateCompositeRepositoryTask() { >+ createApp = new CreateCompositeRepositoryApplication(); >+ modifyApp = new ModifyCompositeRepositoryApplication(); >+ modifyApp.setRemoveUnknownRepositories(false); >+ } >+ >+ /* (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()); >+ } >+ if (add) { >+ 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 setFailOnExists(boolean value) { >+ createApp.setFailOnExists(value); >+ } >+ >+ /* >+ * Add a list of child repositories to add to the newly created repository >+ */ >+ public void addConfiguredAdd(RepositoryList addList) { >+ add = true; >+ 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/ModifyCompositeRepositoryApplication.java >=================================================================== >RCS file: src/org/eclipse/equinox/p2/internal/repository/tools/ModifyCompositeRepositoryApplication.java >diff -N src/org/eclipse/equinox/p2/internal/repository/tools/ModifyCompositeRepositoryApplication.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/ModifyCompositeRepositoryApplication.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * 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; >+ >+public class ModifyCompositeRepositoryApplication 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.isArtifact()) >+ artifactRepo.removeChild(child.getRepoLocation()); >+ if (child.isMetadata()) >+ metadataRepo.removeChild(child.getRepoLocation()); >+ } >+ >+ // Add children to the Composite Repositories >+ for (Iterator iterator = childrenToAdd.iterator(); iterator.hasNext();) { >+ RepositoryDescriptor child = (RepositoryDescriptor) iterator.next(); >+ if (child.isArtifact()) >+ artifactRepo.addChild(child.getRepoLocation()); >+ if (child.isMetadata()) >+ metadataRepo.addChild(child.getRepoLocation()); >+ } >+ return Status.OK_STATUS; >+ } finally { >+ finalizeRepositories(); >+ } >+ } >+ >+ public void setRemoveUnknownRepositories(boolean value) { >+ removeUnknownRepositories = value; >+ } >+ >+ 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