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 134001 Details for
Bug 274576
[publisher] Make the publisher ant task consistent with the others
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]
Patch
publisherTask.txt (text/plain), 39.80 KB, created by
Pascal Rapicault
on 2009-04-30 15:32:52 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Pascal Rapicault
Created:
2009-04-30 15:32:52 EDT
Size:
39.80 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.publisher >Index: .externalToolBuilders/Build Publisher Ant Tasks.launch >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher/.externalToolBuilders/Build Publisher Ant Tasks.launch,v >retrieving revision 1.5 >diff -u -r1.5 Build Publisher Ant Tasks.launch >--- .externalToolBuilders/Build Publisher Ant Tasks.launch 27 Jan 2009 16:15:27 -0000 1.5 >+++ .externalToolBuilders/Build Publisher Ant Tasks.launch 27 Apr 2009 22:12:24 -0000 >@@ -1,13 +1,12 @@ >-<?xml version="1.0" encoding="UTF-8"?> >-<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> >+<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> > <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> > <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> > <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/> > <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> >-<listEntry value="/org.eclipse.equinox.p2.publisher/scripts/buildExtraJAR.xml"/> >+<listEntry value="/org.eclipse.equinox.p2.publisher"/> > </listAttribute> > <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> >-<listEntry value="1"/> >+<listEntry value="4"/> > </listAttribute> > <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> > <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> >@@ -17,4 +16,4 @@ > <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.equinox.p2.publisher/scripts/buildExtraJAR.xml}"/> > <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> > <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> >-</launchConfiguration> >+</launchConfiguration> >\ No newline at end of file >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/messages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/messages.properties,v >retrieving revision 1.1 >diff -u -r1.1 messages.properties >--- src_ant/org/eclipse/equinox/internal/p2/publisher/ant/messages.properties 26 Sep 2008 18:04:13 -0000 1.1 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/messages.properties 27 Apr 2009 22:12:24 -0000 >@@ -12,3 +12,12 @@ > exception_errorOccurredCallingGenerator = An error occurred when calling generator. > exception_errorArtifactRepo = Error setting artifact repository {0}. > exception_errorMetadataRepo = Error setting metadata repository {0}. >+ >+AbstractApplication_no_valid_destinations=Unable to locate a valid destination repository. >+exception_invalidDestination=Invalid destination repository location: {0}. >+exception_invalidSource=Invalid source repository location: {0}. >+unknown_repository_type=Repository is of an unknown type: {0} >+ >+DestinationNotModifiable=Destination repository is not modifiable: {0} >+locationMustBeAbsolute=Location must be absolute >+schemeNotSupported=Scheme not supported >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/TaskMessages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/TaskMessages.java,v >retrieving revision 1.1 >diff -u -r1.1 TaskMessages.java >--- src_ant/org/eclipse/equinox/internal/p2/publisher/ant/TaskMessages.java 26 Sep 2008 18:04:13 -0000 1.1 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/TaskMessages.java 27 Apr 2009 22:12:24 -0000 >@@ -19,6 +19,15 @@ > public static String exception_errorArtifactRepo; > public static String exception_errorMetadataRepo; > >+ public static String AbstractApplication_no_valid_destinations; >+ public static String exception_invalidDestination; >+ public static String exception_invalidSource; >+ public static String unknown_repository_type; >+ >+ public static String DestinationNotModifiable; >+ public static String locationMustBeAbsolute; >+ public static String schemeNotSupported; >+ > static { > // load message values from bundle file > NLS.initializeMessages(BUNDLE_NAME, TaskMessages.class); >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.publisher/src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java,v >retrieving revision 1.6 >diff -u -r1.6 AbstractPublishTask.java >--- src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java 25 Feb 2009 03:45:32 -0000 1.6 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/AbstractPublishTask.java 27 Apr 2009 22:12:24 -0000 >@@ -8,18 +8,22 @@ > ******************************************************************************/ > package org.eclipse.equinox.internal.p2.publisher.ant; > >+import org.eclipse.equinox.internal.p2.publisher.ant.repository.*; >+ > import java.net.URI; > import java.net.URISyntaxException; > import java.util.*; >-import org.apache.tools.ant.Task; > 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.p2.publisher.Messages; >+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.repository.IMetadataRepository; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; > import org.eclipse.equinox.p2.publisher.*; > >-public abstract class AbstractPublishTask extends Task { >+public abstract class AbstractPublishTask extends AbstractRepositoryTask { > protected static final String ANT_PROPERTY_PREFIX = "${"; //$NON-NLS-1$ > > /** >@@ -83,38 +87,53 @@ > protected String artifactRepoName; > protected PublisherInfo provider = null; > protected List contextRepositories = new ArrayList(); >+ protected PublisherApplication app; >+ >+ public AbstractPublishTask() { >+ app = new PublisherApplication(); >+ application = app; >+ } > > protected IStatus createConfigurationEror(String message) { > return new Status(IStatus.ERROR, "org.eclipse.equinox.p2.publisher", message); //$NON-NLS-1$ > } > > protected void initializeRepositories(PublisherInfo info) throws ProvisionException { >- if (artifactLocation != null) >+ prepareSourceRepos(); >+ app.initializeRepos(new NullProgressMonitor()); >+ >+ if (app.getArtifactRepository() != null) { >+ IArtifactRepository repo = app.getArtifactRepository(); >+ info.setArtifactRepository(Publisher.createArtifactRepository(repo.getLocation(), artifactRepoName, append, (repo.getProperties().get(IRepository.PROP_COMPRESSED) == null) ? compress : Boolean.valueOf((String) repo.getProperties().get(IRepository.PROP_COMPRESSED)).booleanValue(), reusePackedFiles)); >+ } else if (artifactLocation != null) > info.setArtifactRepository(Publisher.createArtifactRepository(artifactLocation, artifactRepoName, append, compress, reusePackedFiles)); > else if ((info.getArtifactOptions() & IPublisherInfo.A_PUBLISH) > 0) > throw new ProvisionException(createConfigurationEror(Messages.exception_noArtifactRepo)); >- if (metadataLocation == null) >- throw new ProvisionException(createConfigurationEror(Messages.exception_noMetadataRepo)); >- info.setMetadataRepository(Publisher.createMetadataRepository(metadataLocation, metadataRepoName, append, compress)); > >- if (contextRepositories.size() > 0) { >- CompositeMetadataRepository contextMetadata = CompositeMetadataRepository.createMemoryComposite(); >- CompositeArtifactRepository contextArtifact = CompositeArtifactRepository.createMemoryComposite(); >- >- for (Iterator iterator = contextRepositories.iterator(); iterator.hasNext();) { >- RepoEntry entry = (RepoEntry) iterator.next(); >- if (contextMetadata != null && entry.isMetadataRepository()) >- contextMetadata.addChild(entry.getRepositoryLocation()); >- if (contextArtifact != null && entry.isArtifactRepository()) >- contextArtifact.addChild(entry.getRepositoryLocation()); >- } >+ if (app.getMetadataRepository() != null) { >+ IMetadataRepository repo = app.getMetadataRepository(); >+ info.setMetadataRepository(Publisher.createMetadataRepository(repo.getLocation(), metadataRepoName, append, (repo.getProperties().get(IRepository.PROP_COMPRESSED) == null) ? compress : Boolean.valueOf((String) repo.getProperties().get(IRepository.PROP_COMPRESSED)).booleanValue())); >+ } else if (metadataLocation != null) >+ info.setMetadataRepository(Publisher.createMetadataRepository(metadataLocation, metadataRepoName, append, compress)); >+ else >+ throw new ProvisionException(createConfigurationEror(Messages.exception_noMetadataRepo)); > >- if (contextMetadata != null && contextMetadata.getChildren().size() > 0) >- info.setContextMetadataRepository(contextMetadata); >+ CompositeArtifactRepository contextArtifact = (CompositeArtifactRepository) app.getCompositeArtifactRepository(); >+ CompositeMetadataRepository contextMetadata = (CompositeMetadataRepository) app.getCompositeMetadataRepository(); > >- if (contextArtifact != null && contextArtifact.getChildren().size() > 0) >- info.setContextArtifactRepository(contextArtifact); >+ for (Iterator iterator = contextRepositories.iterator(); iterator.hasNext();) { >+ RepoEntry entry = (RepoEntry) iterator.next(); >+ if (contextMetadata != null && entry.isMetadataRepository()) >+ contextMetadata.addChild(entry.getRepositoryLocation()); >+ if (contextArtifact != null && entry.isArtifactRepository()) >+ contextArtifact.addChild(entry.getRepositoryLocation()); > } >+ >+ if (contextMetadata != null && contextMetadata.getChildren().size() > 0) >+ info.setContextMetadataRepository(contextMetadata); >+ >+ if (contextArtifact != null && contextArtifact.getChildren().size() > 0) >+ info.setContextArtifactRepository(contextArtifact); > } > > protected PublisherInfo getInfo() { >@@ -180,4 +199,11 @@ > public void addConfiguredContextRepository(RepoEntry repo) { > contextRepositories.add(repo); > } >+ >+ /* >+ * Allows a list of <repository> elements >+ */ >+ public void addConfiguredContext(RepositoryList list) { >+ addConfiguredSource(list); >+ } > } >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/DestinationRepository.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/DestinationRepository.java >diff -N src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/DestinationRepository.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/DestinationRepository.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,60 @@ >+/******************************************************************************* >+ * 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.internal.p2.publisher.ant.repository; >+ >+import java.net.URISyntaxException; >+import org.apache.tools.ant.BuildException; >+import org.apache.tools.ant.types.DataType; >+import org.eclipse.core.runtime.URIUtil; >+ >+/* >+ * Methods copied from org.eclipse.equinox.p2.internal.repository.tools.tasks.DestinationRepository >+ */ >+public class DestinationRepository extends DataType { >+ >+ private RepositoryDescriptor descriptor = new RepositoryDescriptor(); >+ >+ public void setCompressed(boolean compress) { >+ descriptor.setCompressed(compress); >+ } >+ >+ public void setName(String repoName) { >+ descriptor.setName(repoName); >+ } >+ >+ public void setLocation(String repoLocation) throws BuildException { >+ try { >+ descriptor.setLocation(URIUtil.fromString(repoLocation)); >+ } catch (URISyntaxException e) { >+ throw new BuildException(e); >+ } >+ } >+ >+ public void setFormat(String formatLocation) { >+ try { >+ descriptor.setFormat(URIUtil.fromString(formatLocation)); >+ } catch (URISyntaxException e) { >+ throw new BuildException(e); >+ } >+ } >+ >+ public void setAppend(boolean appendMode) { >+ descriptor.setAppend(appendMode); >+ } >+ >+ public void setKind(String repoKind) { >+ descriptor.setKind(repoKind); >+ } >+ >+ public RepositoryDescriptor getDescriptor() { >+ return descriptor; >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/PublisherApplication.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/PublisherApplication.java >diff -N src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/PublisherApplication.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/PublisherApplication.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,213 @@ >+package org.eclipse.equinox.internal.p2.publisher.ant.repository; >+ >+import java.net.*; >+import java.util.*; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository; >+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; >+import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository; >+import org.eclipse.equinox.internal.p2.publisher.Activator; >+import org.eclipse.equinox.internal.p2.publisher.ant.TaskMessages; >+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.*; >+import org.eclipse.osgi.util.NLS; >+ >+/* >+ * Methods copied from org.eclipse.equinox.p2.internal.repository.tools.tasks.PublisherApplication >+ */ >+public class PublisherApplication { >+ >+ private IArtifactRepository destinationArtifactRepository = null; >+ private IMetadataRepository destinationMetadataRepository = null; >+ >+ private CompositeMetadataRepository compositeMetadataRepository = null; >+ private CompositeArtifactRepository compositeArtifactRepository = null; >+ >+ private List sourceRepositories = new ArrayList(); >+ private List destinationRepos = new ArrayList(); >+ private List artifactReposToRemove = new ArrayList(); >+ private List metadataReposToRemove = new ArrayList(); >+ >+ public void initializeRepos(IProgressMonitor progress) throws ProvisionException { >+ IArtifactRepositoryManager artifactRepositoryManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); >+ IMetadataRepositoryManager metadataRepositoryManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); >+ 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(TaskMessages.unknown_repository_type, repo.getRepoLocation())); >+ } >+ } catch (ProvisionException e) { >+ if (e.getCause() instanceof MalformedURLException) { >+ throw new ProvisionException(NLS.bind(TaskMessages.exception_invalidSource, curLocation), e); >+ } >+ throw e; >+ } >+ processDestinationRepos(artifactRepositoryManager, metadataRepositoryManager); >+ } >+ >+ private void processDestinationRepos(IArtifactRepositoryManager artifactRepositoryManager, IMetadataRepositoryManager metadataRepositoryManager) throws ProvisionException { >+ 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); >+ } >+ >+ 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 >+ } >+ >+ 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 >+ //No existing repository; create a new repository at destinationLocation but with source's attributes. >+ 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(TaskMessages.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(toInit.getFormat(), 0, null); >+ } catch (ProvisionException 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. >+ 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(TaskMessages.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 IArtifactRepository getArtifactRepository() { >+ return destinationArtifactRepository; >+ } >+ >+ public IMetadataRepository getMetadataRepository() { >+ return destinationMetadataRepository; >+ } >+ >+ public List getContextRepositories() { >+ return sourceRepositories; >+ } >+ >+ public void addSource(RepositoryDescriptor descriptor) { >+ sourceRepositories.add(descriptor); >+ } >+ >+ public IMetadataRepository getCompositeMetadataRepository() { >+ if (compositeMetadataRepository == null) { >+ try { >+ compositeMetadataRepository = new CompositeMetadataRepository(new URI("memory:/composite"), "parent metadata repo", null);//$NON-NLS-1$ //$NON-NLS-2$ >+ } catch (URISyntaxException e) { >+ //Can't happen >+ } >+ for (Iterator iter = sourceRepositories.iterator(); iter.hasNext();) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ if (repo.isMetadata()) >+ compositeMetadataRepository.addChild(repo.getRepoLocation()); >+ } >+ } >+ return compositeMetadataRepository; >+ } >+ >+ public IArtifactRepository getCompositeArtifactRepository() { >+ if (compositeArtifactRepository == null) { >+ try { >+ 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 = sourceRepositories.iterator(); iter.hasNext();) { >+ RepositoryDescriptor repo = (RepositoryDescriptor) iter.next(); >+ if (repo.isArtifact()) >+ compositeArtifactRepository.addChild(repo.getRepoLocation()); >+ } >+ } >+ return compositeArtifactRepository; >+ } >+ >+ //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); >+ } >+ >+ //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); >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/AbstractRepositoryTask.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/AbstractRepositoryTask.java >diff -N src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/AbstractRepositoryTask.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/AbstractRepositoryTask.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+package org.eclipse.equinox.internal.p2.publisher.ant.repository; >+ >+import java.io.File; >+import java.net.URI; >+import java.util.*; >+import org.apache.tools.ant.*; >+import org.apache.tools.ant.types.FileSet; >+import org.eclipse.core.runtime.URIUtil; >+import org.eclipse.equinox.internal.p2.publisher.ant.TaskMessages; >+import org.eclipse.osgi.util.NLS; >+ >+/* >+ * Methods copied from org.eclipse.equinox.p2.internal.repository.tools.tasks.AbstractRepositoryTask >+ */ >+public abstract class AbstractRepositoryTask extends Task { >+ protected static final String ANT_PREFIX = "${"; //$NON-NLS-1$ >+ private List sourceRepos = new ArrayList(); >+ protected PublisherApplication application; >+ >+ /* >+ * 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()); >+ } >+ >+ for (Iterator iter = sourceList.getFileSetList().iterator(); iter.hasNext();) { >+ FileSet fileSet = (FileSet) iter.next(); >+ sourceRepos.add(fileSet); >+ // Added to the application later through prepareSourceRepos >+ } >+ } >+ >+ /* >+ * If the user specified some source repositories via sub-elements >+ * then add them to the transformer for consideration. >+ */ >+ protected void prepareSourceRepos() { >+ if (sourceRepos == null || sourceRepos.isEmpty()) >+ return; >+ for (Iterator iter = sourceRepos.iterator(); iter.hasNext();) { >+ RepositoryFileSet fileset = (RepositoryFileSet) iter.next(); >+ >+ 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()) { >+ addArtifactSourceRepository(uri); >+ addMetadataSourceRepository(uri); >+ } else if (fileset.isArtifact()) >+ addArtifactSourceRepository(uri); >+ else if (fileset.isMetadata()) >+ addMetadataSourceRepository(uri); >+ else >+ throw new BuildException(NLS.bind(TaskMessages.unknown_repository_type, uri)); >+ } >+ } >+ } >+ } >+ sourceRepos.clear(); >+ } >+ >+ protected void addMetadataSourceRepository(URI repoLocation) { >+ RepositoryDescriptor source = new RepositoryDescriptor(); >+ source.setLocation(repoLocation); >+ source.setKind(RepositoryDescriptor.KIND_METADATA); >+ application.addSource(source); >+ } >+ >+ protected void addArtifactSourceRepository(URI repoLocation) { >+ RepositoryDescriptor source = new RepositoryDescriptor(); >+ source.setLocation(repoLocation); >+ source.setKind(RepositoryDescriptor.KIND_ARTIFACT); >+ application.addSource(source); >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryFileSet.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryFileSet.java >diff -N src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryFileSet.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryFileSet.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * 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.internal.p2.publisher.ant.repository; >+ >+import org.apache.tools.ant.types.FileSet; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >+ >+/* >+ * Methods copied from org.eclipse.equinox.p2.internal.repository.tools.tasks.RepositoryFileSet >+ */ >+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; >+ >+ 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; >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryDescriptor.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryDescriptor.java >diff -N src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryDescriptor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryDescriptor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,112 @@ >+/******************************************************************************* >+ * 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.internal.p2.publisher.ant.repository; >+ >+import java.net.URI; >+import org.eclipse.equinox.internal.p2.publisher.ant.TaskMessages; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >+import org.eclipse.osgi.util.NLS; >+ >+/* >+ * Methods copied from org.eclipse.equinox.p2.internal.repository.tools.tasks.RepositoryDescriptor >+ */ >+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 URI format = null; >+ private int kind = TYPE_BOTH; >+ >+ public void setCompressed(boolean compress) { >+ compressed = compress; >+ } >+ >+ public void setName(String repoName) { >+ name = repoName; >+ } >+ >+ public void setLocation(URI repoLocation) { >+ location = RepositoryHelper.localRepoURIHelper(repoLocation); >+ } >+ >+ public void setFormat(URI format) { >+ this.format = RepositoryHelper.localRepoURIHelper(format); >+ } >+ >+ public void setAppend(boolean appendMode) { >+ append = appendMode; >+ } >+ >+ public boolean isCompressed() { >+ return compressed; >+ } >+ >+ public boolean isAppend() { >+ return append; >+ } >+ >+ public String getName() { >+ return name; >+ } >+ >+ public URI getRepoLocation() { >+ return location; >+ } >+ >+ public URI getFormat() { >+ return format; >+ } >+ >+ public int getKind() { >+ 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) { >+ kind = determineKind(repoKind); >+ } >+ >+ /* >+ * 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(TaskMessages.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_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryList.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryList.java >diff -N src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryList.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryList.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,43 @@ >+/******************************************************************************* >+ * 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.internal.p2.publisher.ant.repository; >+ >+import java.util.ArrayList; >+import java.util.List; >+import org.apache.tools.ant.types.DataType; >+ >+/* >+ * Methods copied from org.eclipse.equinox.p2.internal.repository.tools.tasks.RepositoryFileSet >+ */ >+public class RepositoryList extends DataType { >+ 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() { >+ return sourceFileSets; >+ } >+} >Index: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryHelper.java >=================================================================== >RCS file: src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryHelper.java >diff -N src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src_ant/org/eclipse/equinox/internal/p2/publisher/ant/repository/RepositoryHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/******************************************************************************* >+ * 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 >+ * Cloudsmith Inc - ongoing implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.p2.publisher.ant.repository; >+ >+import java.io.File; >+import java.net.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.equinox.internal.p2.publisher.Activator; >+import org.eclipse.equinox.internal.p2.publisher.ant.TaskMessages; >+import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; >+import org.eclipse.osgi.util.NLS; >+ >+/* >+ * Methods copied from org.eclipse.equinox.p2.internal.repository.tools.tasks.RepositoryFileSet >+ */ >+public class RepositoryHelper { >+ protected static final String FILE_SCHEME = "file"; //$NON-NLS-1$ >+ >+ /** >+ * If the provided URI can be interpreted as representing a local address (no schema, or one letter schema) >+ * but is missing the file schema, a new URI is created which represents the local file. >+ * >+ * @param location the URI to convert >+ * @return the converted URI, or the original >+ */ >+ public static URI localRepoURIHelper(URI location) { >+ if (location == null) >+ return null; >+ if (location.getScheme() == null) >+ // Probably a local path: /home/user/repo >+ location = (new File(location.getPath())).getAbsoluteFile().toURI(); >+ else if (location.getScheme().length() == 1) >+ // Probably a windows path: C:\repo >+ location = (new File(URIUtil.toUnencodedString(location))).toURI(); >+ else if (!FILE_SCHEME.equalsIgnoreCase(location.getScheme())) >+ // This else must occur last! >+ return location; >+ >+ // Zipped repository? >+ String lowerCase = location.toString().toLowerCase(); >+ if (lowerCase.endsWith(".jar") || lowerCase.endsWith(".zip")) //$NON-NLS-1$//$NON-NLS-2$ >+ return URIUtil.toJarURI(location, null); >+ return location; >+ } >+ >+ /** >+ * Determine if the repository could be used as a valid destination (eg, it is modifiable) >+ * @param repository the repository to test >+ * @return the repository >+ */ >+ public static IRepository validDestinationRepository(IRepository repository) { >+ if (!repository.isModifiable()) >+ throw new IllegalStateException(NLS.bind(TaskMessages.DestinationNotModifiable, repository.getLocation())); >+ return repository; >+ } >+ >+ /** >+ * Determine if the location is a syntactically correct repository location. Intended to be used >+ * from the UI when checking validity of user input. >+ * >+ * @throws IllegalArgumentException if location is null >+ */ >+ public static IStatus checkRepositoryLocationSyntax(URI location) { >+ if (location == null) >+ throw new IllegalArgumentException("Location cannot be null"); //$NON-NLS-1$ >+ if (!location.isAbsolute()) >+ return new Status(IStatus.ERROR, Activator.ID, TaskMessages.locationMustBeAbsolute); >+ try { >+ new URL(location.getScheme(), "dummy.com", -1, "dummy.txt"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } catch (MalformedURLException e) { >+ return new Status(IStatus.ERROR, Activator.ID, TaskMessages.schemeNotSupported); >+ >+ } >+ return Status.OK_STATUS; >+ } >+} >\ No newline at end of file
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 274576
: 134001 |
134065