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 132782 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]
Ant Tasks
Ant.patch (text/plain), 81.53 KB, created by
Matthew Piggott
on 2009-04-22 10:52:30 EDT
(
hide
)
Description:
Ant Tasks
Filename:
MIME Type:
Creator:
Matthew Piggott
Created:
2009-04-22 10:52:30 EDT
Size:
81.53 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.repository.tools >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 22 Apr 2009 14:51:55 -0000 >@@ -15,6 +15,12 @@ > library="lib/repository-tools-ant.jar" > name="p2.mirror"> > </antTask> >+ >+ <antTask >+ class="org.eclipse.equinox.p2.internal.repository.tools.tasks.CompositeRepositoryTask" >+ library="lib/repository-tools-ant.jar" >+ name="p2.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 22 Apr 2009 14:51:55 -0000 >@@ -10,10 +10,10 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.internal.repository.tools; > >-import java.net.URI; >-import java.net.URISyntaxException; >+import java.net.*; > 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,13 +22,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 removeAddedRepositories = true; > >- protected List sourceArtifactRepositories = new ArrayList(); >- protected List sourceMetadataRepositories = new ArrayList(); >+ protected List sourceRepositories = new ArrayList(); //List of repository descriptors > protected List artifactReposToRemove = new ArrayList(); > protected List metadataReposToRemove = new ArrayList(); > protected List sourceIUs = new ArrayList(); >@@ -40,92 +40,89 @@ > private CompositeMetadataRepository compositeMetadataRepository = null; > private CompositeArtifactRepository compositeArtifactRepository = null; > >- public void addSourceMetadataRepository(String location) { >- URI uri = Activator.getURI(location); >- if (uri != null) >- sourceMetadataRepositories.add(RepositoryHelper.localRepoURIHelper(uri)); >- } >- >- public void addSourceMetadataRepository(URI location) { >- if (location != null) >- sourceMetadataRepositories.add(RepositoryHelper.localRepoURIHelper(location)); >- } >- >- public List getSourceMetadataRepositories() { >- return sourceMetadataRepositories; >- } >- >- public void addSourceArtifactRepository(String location) { >- URI uri = Activator.getURI(location); >- if (uri != null) >- sourceArtifactRepositories.add(RepositoryHelper.localRepoURIHelper(uri)); >- } >- >- public void addSourceArtifactRepository(URI location) { >- if (location != null) >- sourceArtifactRepositories.add(RepositoryHelper.localRepoURIHelper(location)); >- } >- > public void setSourceIUs(List ius) { > sourceIUs = ius; > } > > 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 (removeAddedRepositories) { >+ 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 { > IArtifactRepositoryManager artifactRepositoryManager = Activator.getArtifactRepositoryManager(); >- if (sourceArtifactRepositories != null && !sourceArtifactRepositories.isEmpty()) { >- for (Iterator iter = sourceArtifactRepositories.iterator(); iter.hasNext();) { >- URI repoLocation = (URI) iter.next(); >- if (!artifactRepositoryManager.contains(repoLocation)) >- artifactReposToRemove.add(repoLocation); >- artifactRepositoryManager.loadRepository(repoLocation, 0, progress); >- } >- } >- > IMetadataRepositoryManager metadataRepositoryManager = Activator.getMetadataRepositoryManager(); >- if (sourceMetadataRepositories != null && !sourceMetadataRepositories.isEmpty()) { >- for (Iterator iter = sourceMetadataRepositories.iterator(); iter.hasNext();) { >- URI repoLocation = (URI) iter.next(); >- if (!metadataRepositoryManager.contains(repoLocation)) >- metadataReposToRemove.add(repoLocation); >- metadataRepositoryManager.loadRepository(repoLocation, 0, progress); >+ URI curLocation = null; >+ try { >+ for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ curLocation = repo.getRepoLocation(); >+ if (repo.isBoth()) { >+ addRepository(artifactRepositoryManager, curLocation, 0, progress); >+ addRepository(metadataRepositoryManager, curLocation, 0, progress); >+ } else if (repo.isArtifact()) >+ addRepository(artifactRepositoryManager, curLocation, 0, progress); >+ else if (repo.isMetadata()) >+ addRepository(metadataRepositoryManager, curLocation, 0, progress); >+ else >+ throw new ProvisionException(NLS.bind(Messages.unknown_repository_type, repo.getRepoLocation())); >+ } >+ } catch (ProvisionException e) { >+ if (e.getCause() instanceof MalformedURLException) { >+ throw new ProvisionException(NLS.bind(Messages.exception_invalidSource, curLocation), e); > } >+ throw e; > } >- > processDestinationRepos(artifactRepositoryManager, metadataRepositoryManager); >+ } > >+ //Helper to add a repository. It takes care of adding the repos to the deletion list and loading it >+ protected IMetadataRepository addRepository(IMetadataRepositoryManager manager, URI location, int flags, IProgressMonitor monitor) throws ProvisionException { >+ if (!manager.contains(location)) >+ metadataReposToRemove.add(location); >+ return manager.loadRepository(location, flags, monitor); >+ } >+ >+ //Helper to add a repository. It takes care of adding the repos to the deletion list and loading it >+ protected IArtifactRepository addRepository(IArtifactRepositoryManager manager, URI location, int flags, IProgressMonitor monitor) throws ProvisionException { >+ if (!manager.contains(location)) >+ artifactReposToRemove.add(location); >+ return manager.loadRepository(location, flags, monitor); > } > > 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(); >+ if (repo.isArtifact() && artifactRepoDescriptor == null) >+ artifactRepoDescriptor = repo; >+ if (repo.isMetadata() && 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); >- } >- >- private IMetadataRepository initializeDestination(RepositoryDescriptor toInit, IMetadataRepositoryManager mgr) throws ProvisionException { >- try { >- 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 (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); >+ } >+ >+ protected IMetadataRepository initializeDestination(RepositoryDescriptor toInit, IMetadataRepositoryManager mgr) throws ProvisionException { >+ try { >+ IMetadataRepository repository = addRepository(mgr, toInit.getRepoLocation(), IRepositoryManager.REPOSITORY_HINT_MODIFIABLE, null); >+ if (initDestinationRepository(repository, toInit)) > return repository; >- } > } catch (ProvisionException e) { > //fall through and create a new repository below > } >@@ -133,51 +130,63 @@ > 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. >- IMetadataRepository result = mgr.createRepository(toInit.getRepoLocation(), toInit.getName() != null ? toInit.getName() : (source != null ? source.getName() : toInit.getRepoLocation().toString()), IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, source != null ? source.getProperties() : null); >- if (toInit.isCompressed() && !result.getProperties().containsKey(IRepository.PROP_COMPRESSED)) >- result.setProperty(IRepository.PROP_COMPRESSED, "true"); //$NON-NLS-1$ >- return (IMetadataRepository) RepositoryHelper.validDestinationRepository(result); >- } >- >- private IArtifactRepository initializeDestination(RepositoryDescriptor toInit, IArtifactRepositoryManager mgr) throws ProvisionException { >- try { >- 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(); >+ try { >+ IMetadataRepository result = mgr.createRepository(toInit.getRepoLocation(), toInit.getName() != null ? toInit.getName() : (source != null ? source.getName() : toInit.getRepoLocation().toString()), IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, source != null ? source.getProperties() : null); >+ if (toInit.isCompressed() && !result.getProperties().containsKey(IRepository.PROP_COMPRESSED)) >+ result.setProperty(IRepository.PROP_COMPRESSED, "true"); //$NON-NLS-1$ >+ return (IMetadataRepository) RepositoryHelper.validDestinationRepository(result); >+ } catch (UnsupportedOperationException e) { >+ throw new ProvisionException(NLS.bind(Messages.exception_invalidDestination, toInit.getRepoLocation()), e.getCause()); >+ } >+ } >+ >+ protected IArtifactRepository initializeDestination(RepositoryDescriptor toInit, IArtifactRepositoryManager mgr) throws ProvisionException { >+ try { >+ IArtifactRepository repository = addRepository(mgr, toInit.getRepoLocation(), IRepositoryManager.REPOSITORY_HINT_MODIFIABLE, null); >+ 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. > // TODO for now create a Simple repo by default. >- IArtifactRepository result = mgr.createRepository(toInit.getRepoLocation(), toInit.getName() != null ? toInit.getName() : (source != null ? source.getName() : toInit.getRepoLocation().toString()), IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, source != null ? source.getProperties() : null); >- if (toInit.isCompressed() && !result.getProperties().containsKey(IRepository.PROP_COMPRESSED)) >- result.setProperty(IRepository.PROP_COMPRESSED, "true"); //$NON-NLS-1$ >- return (IArtifactRepository) RepositoryHelper.validDestinationRepository(result); >+ try { >+ IArtifactRepository result = mgr.createRepository(toInit.getRepoLocation(), toInit.getName() != null ? toInit.getName() : (source != null ? source.getName() : toInit.getRepoLocation().toString()), IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, source != null ? source.getProperties() : null); >+ if (toInit.isCompressed() && !result.getProperties().containsKey(IRepository.PROP_COMPRESSED)) >+ result.setProperty(IRepository.PROP_COMPRESSED, "true"); //$NON-NLS-1$ >+ return (IArtifactRepository) RepositoryHelper.validDestinationRepository(result); >+ } catch (UnsupportedOperationException e) { >+ throw new ProvisionException(NLS.bind(Messages.exception_invalidDestination, toInit.getRepoLocation()), e.getCause()); >+ } >+ } >+ >+ protected 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() { >@@ -187,8 +196,10 @@ > } catch (URISyntaxException e) { > //Can't happen > } >- for (Iterator iter = sourceMetadataRepositories.iterator(); iter.hasNext();) { >- compositeMetadataRepository.addChild((URI) iter.next()); >+ for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ if (repo.isMetadata()) >+ compositeMetadataRepository.addChild(repo.getRepoLocation()); > } > } > return compositeMetadataRepository; >@@ -197,20 +208,34 @@ > 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 > } >- for (Iterator iter = sourceArtifactRepositories.iterator(); iter.hasNext();) { >- compositeArtifactRepository.addChild((URI) iter.next()); >+ for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ if (repo.isArtifact()) >+ compositeArtifactRepository.addChild(repo.getRepoLocation()); > } > } > return compositeArtifactRepository; > } > >+ protected boolean hasArtifactSources() { >+ return !((ICompositeRepository) getCompositeArtifactRepository()).getChildren().isEmpty(); >+ } >+ >+ protected boolean hasMetadataSources() { >+ return !((ICompositeRepository) getCompositeMetadataRepository()).getChildren().isEmpty(); >+ } >+ > public abstract IStatus run(IProgressMonitor monitor) throws ProvisionException; > > 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 22 Apr 2009 14:51:55 -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 22 Apr 2009 14:51:55 -0000 >@@ -10,45 +10,73 @@ > *******************************************************************************/ > 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.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; > > 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 +86,33 @@ > 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; >+ return addRepository(Activator.getArtifactRepositoryManager(), baseline, 0, null); > } > > private void mirrorMetadata(IQueryable slice, IProgressMonitor monitor) { >@@ -75,21 +127,145 @@ > * 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 (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(); > } > >- private IQueryable slice(IProgressMonitor monitor) { >+ /* >+ * 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) throws ProvisionException { > if (slicingOptions == null) > slicingOptions = new SlicingOptions(); > PermissiveSlicer slicer = new PermissiveSlicer(getCompositeMetadataRepository(), slicingOptions.getFilter(), slicingOptions.includeOptionalDependencies(), slicingOptions.isEverythingGreedy(), slicingOptions.forceFilterTo(), slicingOptions.considerStrictDependencyOnly()); >- return slicer.slice((IInstallableUnit[]) sourceIUs.toArray(new IInstallableUnit[sourceIUs.size()]), monitor); >+ IQueryable slice = slicer.slice((IInstallableUnit[]) sourceIUs.toArray(new IInstallableUnit[sourceIUs.size()]), monitor); >+ if (slice == null) >+ throw new ProvisionException(slicer.getStatus()); >+ return slice; > } > > 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/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 22 Apr 2009 14:51:55 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.internal.repository.tools; > >-import java.net.URI; > import java.net.URISyntaxException; > import java.util.*; > import org.eclipse.core.runtime.*; >@@ -27,7 +26,6 @@ > 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.metadata.repository.IMetadataRepositoryManager; > import org.eclipse.equinox.internal.provisional.p2.query.Collector; > > /** >@@ -165,11 +163,11 @@ > return; > } > // get all IUs from the repos >- if (sourceMetadataRepositories == null || sourceMetadataRepositories.isEmpty()) >+ if (!hasMetadataSources()) > throw new ProvisionException(Messages.exception_needIUsOrNonEmptyRepo); >- for (Iterator iter = sourceMetadataRepositories.iterator(); iter.hasNext();) { >- processedIUs.addAll(getAllIUs((URI) iter.next(), monitor).toCollection()); >- } >+ >+ processedIUs.addAll(getAllIUs(getCompositeMetadataRepository(), monitor).toCollection()); >+ > if (processedIUs.isEmpty()) > throw new ProvisionException(Messages.exception_needIUsOrNonEmptyRepo); > } >@@ -188,15 +186,13 @@ > /* > * Return a collector over all the IUs contained in the given repository. > */ >- private Collector getAllIUs(URI location, IProgressMonitor monitor) throws ProvisionException { >+ private Collector getAllIUs(IMetadataRepository repository, IProgressMonitor monitor) { > SubMonitor progress = SubMonitor.convert(monitor, 2); >- IMetadataRepositoryManager manager = Activator.getMetadataRepositoryManager(); >- if (!manager.contains(location)) >- metadataReposToRemove.add(location); >- IMetadataRepository repository = manager.loadRepository(location, progress.newChild(1)); >- Collector result = new Collector(); >- repository.query(InstallableUnitQuery.ANY, result, progress.newChild(1)).iterator(); >- return result; >+ try { >+ return repository.query(InstallableUnitQuery.ANY, new Collector(), progress.newChild(1)); >+ } finally { >+ progress.done(); >+ } > } > > /* >@@ -242,19 +238,15 @@ > String arg = args[++i]; > > if (option.equalsIgnoreCase("-source")) { //$NON-NLS-1$ >- addSourceArtifactRepository(arg); >- addSourceMetadataRepository(arg); >+ RepositoryDescriptor source = new RepositoryDescriptor(); >+ source.setLocation(URIUtil.fromString(arg)); >+ addSource(source); > } > > 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); > } > } > } >@@ -266,7 +258,7 @@ > * to add more if they wish) > */ > private void validate() throws ProvisionException { >- if (sourceMetadataRepositories == null && sourceIUs == null) >+ if (!hasMetadataSources() && sourceIUs == null) > throw new ProvisionException(Messages.exception_needIUsOrNonEmptyRepo); > if (destinationArtifactRepository == null) > throw new ProvisionException(Messages.exception_needDestinationRepo); >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 22 Apr 2009 14:51:55 -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/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 22 Apr 2009 14:51:55 -0000 >@@ -20,6 +20,41 @@ > public static String exception_noEngineService; > public static String exception_needIUsOrNonEmptyRepo; > public static String exception_needDestinationRepo; >+ public static String exception_onlyOneComparator; >+ >+ public static String AbstractApplication_no_valid_destinations; >+ >+ public static String AbstractRepositoryTask_unableToFind; >+ >+ 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; >+ public static String exception_invalidDestination; >+ public static String exception_invalidSource; > > static { > // initialize resource bundles >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 22 Apr 2009 14:51:55 -0000 >@@ -8,10 +8,38 @@ > # Contributors: > # IBM Corporation - initial API and implementation > ############################################################################### >-exception_destinationNotModifiable = The destination repository must be modifiable: {0}. >+AbstractApplication_no_valid_destinations=Unable to locate a valid destination repository. >+AbstractRepositoryTask_unableToFind=Unable to find: {0} >+ >+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_invalidDestination=Invalid destination repository location: {0}. >+exception_invalidSource=Invalid source repository location: {0}. > exception_unableToRemoveRepo=Unable to remove artifact repository file: {0}. > exception_notLocalFileRepo= {0} is not a local file based repository. > exception_noEngineService=Unable to acquire engine service. > exception_needIUsOrNonEmptyRepo=Need to specify either a non-empty source metadata repository or a valid list of IUs. >-exception_needDestinationRepo=Need to set the destination artifact repository location. >\ No newline at end of file >+exception_needDestinationRepo=Need to set the destination artifact repository location. >+exception_onlyOneComparator=Only one comparator should be defined. >\ No newline at end of file >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 22 Apr 2009 14:51:55 -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/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 22 Apr 2009 14:51:55 -0000 >@@ -10,32 +10,57 @@ > *******************************************************************************/ > package org.eclipse.equinox.p2.internal.repository.tools.tasks; > >+import java.io.File; > import java.util.List; > import org.apache.tools.ant.BuildException; > import org.eclipse.core.runtime.IStatus; >+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.Messages; > import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication; > > public class MirrorTask extends AbstractRepositoryTask { > >+ private File mirrorLog; // file to log mirror output to (optional) >+ private ComparatorDescription comparator; >+ > 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)); >+ >+ if (comparator != null) { >+ // Enable comparison >+ ((MirrorApplication) application).setCompare(true); >+ // Set baseline location >+ if (comparator.getBaseline() != null) >+ ((MirrorApplication) application).setBaseline(comparator.getBaseline().getDescriptor().getRepoLocation()); >+ // Set comparator to use >+ if (comparator.getComparator() != null) >+ ((MirrorApplication) application).setComparatorID(comparator.getComparator()); >+ // Set comparator log >+ if (comparator.getComparatorLog() != null) >+ ((MirrorApplication) application).setComparatorLog(comparator.getComparatorLog()); >+ } >+ > 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 +69,46 @@ > ((MirrorApplication) application).setSlicingOptions(options.getOptions()); > return options; > } >+ >+ /* >+ * Set the comparison information >+ */ >+ public ComparatorDescription createComparator() { >+ if (comparator != null) >+ throw new BuildException(Messages.exception_onlyOneComparator); >+ comparator = new ComparatorDescription(); >+ return comparator; >+ } >+ >+ /* >+ * 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/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 22 Apr 2009 14:51:55 -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/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 22 Apr 2009 14:51:55 -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 22 Apr 2009 14:51:55 -0000 >@@ -16,12 +16,14 @@ > 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.*; >+import org.eclipse.osgi.util.NLS; > > public abstract class AbstractRepositoryTask extends Task { > protected static final String ANT_PREFIX = "${"; //$NON-NLS-1$ >@@ -30,21 +32,18 @@ > 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); >+ RepositoryDescriptor source = new RepositoryDescriptor(); >+ source.setLocation(repoLocation); >+ source.setKind(RepositoryDescriptor.KIND_METADATA); >+ application.addSource(source); > } > > protected void addArtifactSourceRepository(URI repoLocation) { >- application.addSourceArtifactRepository(repoLocation); >+ RepositoryDescriptor source = new RepositoryDescriptor(); >+ source.setLocation(repoLocation); >+ source.setKind(RepositoryDescriptor.KIND_ARTIFACT); >+ application.addSource(source); > } > > /* >@@ -61,8 +60,13 @@ > * argument to specify both the artifact and metadata repositories. > */ > public void setSource(String location) { >- application.addSourceArtifactRepository(location); >- application.addSourceMetadataRepository(location); >+ RepositoryDescriptor source = new RepositoryDescriptor(); >+ try { >+ source.setLocation(URIUtil.fromString(location)); >+ application.addSource(source); >+ } catch (URISyntaxException e) { >+ throw new BuildException(e); >+ } > } > > /* >@@ -70,20 +74,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 +90,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 +123,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; >- } >- } >- application.addSourceArtifactRepository(uri); >- application.addSourceMetadataRepository(uri); >+ RepositoryFileSet fileset = (RepositoryFileSet) iter.next(); >+ >+ if (fileset.getRepoLocation() != null) { >+ //TODO depreciate >+ if (!fileset.getRepoLocation().startsWith(ANT_PREFIX)) { >+ addArtifactSourceRepository(fileset.getRepoLocationURI()); >+ addMetadataSourceRepository(fileset.getRepoLocationURI()); >+ } >+ } 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); > } >- } >- } else { >- if (!fileset.location.startsWith(ANT_PREFIX)) { >- application.addSourceArtifactRepository(fileset.location); >- application.addSourceMetadataRepository(fileset.location); >+ if (fileset.isBoth()) { >+ addArtifactSourceRepository(uri); >+ addMetadataSourceRepository(uri); >+ } else if (fileset.isArtifact()) >+ addArtifactSourceRepository(uri); >+ else if (fileset.isMetadata()) >+ addMetadataSourceRepository(uri); >+ else >+ throw new BuildException(NLS.bind(Messages.unknown_repository_type, uri)); > } > } > } >@@ -161,9 +171,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_unableToFind, 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: 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 22 Apr 2009 14:51:55 -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/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/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java >=================================================================== >RCS file: src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java >diff -N src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,173 @@ >+/******************************************************************************* >+ * 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.net.MalformedURLException; >+import java.util.*; >+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 CompositeRepositoryApplication extends AbstractApplication { >+ private List childrenToAdd = new ArrayList(); >+ private List childrenToRemove = new ArrayList(); >+ private boolean failOnExists = false; >+ >+ public IStatus run(IProgressMonitor monitor) throws ProvisionException { >+ try { >+ initializeRepos(new NullProgressMonitor()); >+ // load repository >+ ICompositeRepository metadataRepo = (ICompositeRepository) destinationMetadataRepository; >+ ICompositeRepository artifactRepo = (ICompositeRepository) destinationArtifactRepository; >+ >+ // Remove children from the Composite Repositories >+ for (Iterator iterator = childrenToRemove.iterator(); iterator.hasNext();) { >+ RepositoryDescriptor child = (RepositoryDescriptor) iterator.next(); >+ if (child.isArtifact() && artifactRepo != null) >+ artifactRepo.removeChild(child.getRepoLocation()); >+ if (child.isMetadata() && metadataRepo != null) >+ 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 != null) >+ artifactRepo.addChild(child.getRepoLocation()); >+ if (child.isMetadata() && metadataRepo != null) >+ metadataRepo.addChild(child.getRepoLocation()); >+ } >+ return Status.OK_STATUS; >+ } finally { >+ finalizeRepositories(); >+ } >+ } >+ >+ public void addChild(RepositoryDescriptor child) { >+ childrenToAdd.add(child); >+ } >+ >+ public void removeChild(RepositoryDescriptor child) { >+ childrenToRemove.add(child); >+ } >+ >+ public void setFailOnExists(boolean value) { >+ failOnExists = value; >+ } >+ >+ protected IArtifactRepository initializeDestination(RepositoryDescriptor toInit, IArtifactRepositoryManager mgr) throws ProvisionException { >+ // remove the repo first. >+ mgr.removeRepository(toInit.getRepoLocation()); >+ >+ // first try and load to see if one already exists at that location. >+ try { >+ IArtifactRepository repository = mgr.loadRepository(toInit.getRepoLocation(), null); >+ if (validRepositoryLocation(repository) && initDestinationRepository(repository, toInit)) >+ return repository; >+ throw new ProvisionException(new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.CompositeRepository_composite_repository_exists, toInit.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) { >+ if (e.getCause() instanceof MalformedURLException) >+ throw new ProvisionException(NLS.bind(Messages.exception_invalidDestination, toInit.getRepoLocation()), e.getCause()); >+ throw e; >+ } >+ } >+ >+ IArtifactRepository source = null; >+ try { >+ if (toInit.getFormat() != null) >+ source = mgr.loadRepository(toInit.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 repo = mgr.createRepository(toInit.getRepoLocation(), toInit.getName() != null ? toInit.getName() : (source != null ? source.getName() : Messages.CompositeRepository_default_artifactRepo_name), IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, source != null ? source.getProperties() : null); >+ initRepository(repo, toInit); >+ return repo; >+ } catch (IllegalStateException e) { >+ mgr.removeRepository(toInit.getRepoLocation()); >+ throw e; >+ } >+ } >+ >+ protected IMetadataRepository initializeDestination(RepositoryDescriptor toInit, IMetadataRepositoryManager mgr) throws ProvisionException { >+ // remove the repo first. >+ mgr.removeRepository(toInit.getRepoLocation()); >+ >+ // first try and load to see if one already exists at that location. >+ try { >+ IMetadataRepository repository = mgr.loadRepository(toInit.getRepoLocation(), null); >+ if (!validRepositoryLocation(repository) && initDestinationRepository(repository, toInit)) >+ throw new ProvisionException(new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.CompositeRepository_composite_repository_exists, toInit.getRepoLocation()))); >+ return repository; >+ } catch (ProvisionException e) { >+ // re-throw the exception if we got anything other than "repo not found" >+ if (e.getStatus().getCode() != ProvisionException.REPOSITORY_NOT_FOUND) { >+ if (e.getCause() instanceof MalformedURLException) >+ throw new ProvisionException(NLS.bind(Messages.exception_invalidDestination, toInit.getRepoLocation()), e.getCause()); >+ throw e; >+ } >+ } >+ >+ IMetadataRepository source = null; >+ try { >+ if (toInit.getFormat() != null) >+ source = mgr.loadRepository(toInit.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 repo = mgr.createRepository(toInit.getRepoLocation(), toInit.getName() != null ? toInit.getName() : (source != null ? source.getName() : Messages.CompositeRepository_default_metadataRepo_name), IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, source != null ? source.getProperties() : null); >+ initRepository(repo, toInit); >+ return repo; >+ } catch (IllegalStateException e) { >+ mgr.removeRepository(toInit.getRepoLocation()); >+ throw e; >+ } >+ } >+ >+ /* >+ * Determine if the repository is valid for this operation >+ */ >+ private boolean validRepositoryLocation(IRepository repository) throws ProvisionException { >+ 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 ProvisionException(NLS.bind(Messages.CompositeRepository_composite_repository_exists, repository.getLocation())); >+ RepositoryHelper.validDestinationRepository(repository); >+ return true; >+ } >+ // 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/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,67 @@ >+/******************************************************************************* >+ * 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.net.URI; >+import java.net.URISyntaxException; >+import org.apache.tools.ant.BuildException; >+import org.apache.tools.ant.types.FileSet; >+import org.eclipse.core.runtime.URIUtil; >+import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper; >+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; >+ } >+ >+ public URI getRepoLocationURI() { >+ // TODO depreciate >+ try { >+ return RepositoryHelper.localRepoURIHelper(URIUtil.fromString(getRepoLocation())); >+ } catch (URISyntaxException e) { >+ throw new BuildException(e); >+ } >+ } >+} >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ComparatorDescription.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ComparatorDescription.java >diff -N src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ComparatorDescription.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/ComparatorDescription.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * 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.io.File; >+import org.apache.tools.ant.types.DataType; >+ >+public class ComparatorDescription extends DataType { >+ >+ DestinationRepository baseline; >+ String comparatorId; >+ File comparatorLog; >+ >+ /* >+ * Set the baseline repository to compare to >+ */ >+ public void addRepository(DestinationRepository value) { >+ this.baseline = value; >+ } >+ >+ /* >+ * Set the comparator to use >+ */ >+ public void setComparator(String value) { >+ comparatorId = value; >+ } >+ >+ /* >+ * Set the log location for the comparator >+ */ >+ public void setComparatorLog(File value) { >+ comparatorLog = value; >+ } >+ >+ public DestinationRepository getBaseline() { >+ return baseline; >+ } >+ >+ public String getComparator() { >+ return comparatorId; >+ } >+ >+ public File getComparatorLog() { >+ return comparatorLog; >+ } >+} >Index: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java >diff -N src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CompositeRepositoryTask.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.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.CompositeRepositoryApplication; >+ >+public class CompositeRepositoryTask extends AbstractRepositoryTask { >+ >+ public CompositeRepositoryTask() { >+ application = new CompositeRepositoryApplication(); >+ } >+ >+ /* (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(); >+ ((CompositeRepositoryApplication) 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(); >+ ((CompositeRepositoryApplication) application).removeChild(repo.getDescriptor()); >+ } >+ } >+ >+ /* >+ * Set whether the task should fail if the repository already exists >+ */ >+ public void setFailOnExists(boolean value) { >+ ((CompositeRepositoryApplication) application).setFailOnExists(value); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 265550
:
126782
|
127893
|
127894
|
128031
|
131327
|
131450
|
131810
|
131811
|
132255
|
132298
|
132421
|
132422
|
132782
|
132783
|
132785
|
132929