Class ModuleArtifactRepository

  • All Implemented Interfaces:
    org.eclipse.core.runtime.IAdaptable, org.eclipse.equinox.p2.query.IQueryable<org.eclipse.equinox.p2.metadata.IArtifactKey>, org.eclipse.equinox.p2.repository.artifact.IArtifactRepository, org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository, org.eclipse.equinox.p2.repository.IRepository<org.eclipse.equinox.p2.metadata.IArtifactKey>, IArtifactFileProvider, IArtifactProvider, IRawArtifactFileProvider, IRawArtifactProvider

    class ModuleArtifactRepository
    extends ArtifactRepositoryBaseImpl<ModuleArtifactRepository.ModuleArtifactDescriptor>
    A p2 artifact repository implementation for the build output directory. Instances are persisted in the following files:
    • A p2artifacts.xml file in the given build target directory, which contains a list of all artifacts with p2 and Maven coordinates. (In particular the classifier part of the Maven coordinates is relevant.) This file is deployed to Maven repositories alongside with the built Tycho artifact.
    • The local-artifacts.properties file, which maps classifiers to the file system locations of the artifacts before they are uploaded into a Maven repository. (Unlike in a Maven repository, there are no predefined locations for the artifacts in the build output directory.)
    See Also:
    RepositoryLayoutHelper.FILE_NAME_P2_ARTIFACTS, RepositoryLayoutHelper.FILE_NAME_LOCAL_ARTIFACTS
    • Field Detail

      • REPOSITORY_TYPE

        public static final java.lang.String REPOSITORY_TYPE
        Type string for this repository type. This value needs to be passed to IArtifactRepositoryManager.createRepository(URI, String, String, Map) in order to create a repository of type ModuleArtifactRepository.
        See Also:
        Constant Field Values
      • DUMMY_GAV

        private static final GAV DUMMY_GAV
      • p2DataFile

        private final java.io.File p2DataFile
      • moduleGAV

        private GAV moduleGAV
    • Constructor Detail

      • ModuleArtifactRepository

        private ModuleArtifactRepository​(org.eclipse.equinox.p2.core.IProvisioningAgent agent,
                                         java.io.File location,
                                         ModuleArtifactMap artifactsMap)
    • Method Detail

      • canAttemptRead

        static boolean canAttemptRead​(java.io.File repositoryDir)
      • restoreInstance

        public static ModuleArtifactRepository restoreInstance​(org.eclipse.equinox.p2.core.IProvisioningAgent agent,
                                                               java.io.File repositoryDir)
                                                        throws org.eclipse.equinox.p2.core.ProvisionException
        Throws:
        org.eclipse.equinox.p2.core.ProvisionException
      • createInstance

        public static ModuleArtifactRepository createInstance​(org.eclipse.equinox.p2.core.IProvisioningAgent agent,
                                                              java.io.File repositoryDir)
                                                       throws org.eclipse.equinox.p2.core.ProvisionException
        Throws:
        org.eclipse.equinox.p2.core.ProvisionException
      • createArtifactLocationMap

        private static ModuleArtifactMap createArtifactLocationMap​(java.io.File repositoryDir)
                                                            throws org.eclipse.equinox.p2.core.ProvisionException
        Throws:
        org.eclipse.equinox.p2.core.ProvisionException
      • setGAV

        public void setGAV​(java.lang.String groupId,
                           java.lang.String artifactId,
                           java.lang.String version)
      • readMavenCoordinates

        private static MavenRepositoryCoordinates readMavenCoordinates​(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
      • getComparableDescriptor

        protected org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor getComparableDescriptor​(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
        Description copied from class: ArtifactRepositoryBaseImpl
        Returns an IArtifactDescriptor instance which is comparable to the artifact descriptors stored in the index (i.e. the ArtifactRepositoryBaseImpl.descriptors member). A valid implementation is to convert the argument to the internal descriptor type ArtifactDescriptorT, but this is not a requirement. This method should be implemented in a way so that calling descriptors.contains(getComparableDescriptor(foreignDescriptor)) with a descriptor from a foreign artifact repository returns true if and only if copying that foreign artifact to this repository with AbstractArtifactRepository2.getOutputStream(IArtifactDescriptor) would not add a new artifact to this repository.

        This method may be called by any API method with an IArtifactDescriptor argument.

        Specified by:
        getComparableDescriptor in class ArtifactRepositoryBaseImpl<ModuleArtifactRepository.ModuleArtifactDescriptor>
        Parameters:
        descriptor - An IArtifactDescriptor from any artifact repository.
      • createArtifactDescriptor

        public ModuleArtifactRepository.ModuleArtifactDescriptor createArtifactDescriptor​(org.eclipse.equinox.p2.metadata.IArtifactKey key)
        Specified by:
        createArtifactDescriptor in interface org.eclipse.equinox.p2.repository.artifact.IArtifactRepository
        Overrides:
        createArtifactDescriptor in class org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository
      • createArtifactDescriptor

        public org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor createArtifactDescriptor​(org.eclipse.equinox.p2.metadata.IArtifactKey key,
                                                                                                       WriteSessionContext writeSession)
      • newAddingArtifactSink

        public IArtifactSink newAddingArtifactSink​(org.eclipse.equinox.p2.metadata.IArtifactKey key,
                                                   WriteSessionContext writeSession)
                                            throws org.eclipse.equinox.p2.core.ProvisionException
        Throws:
        org.eclipse.equinox.p2.core.ProvisionException
      • storeOrProvisioningException

        private void storeOrProvisioningException()
                                           throws org.eclipse.equinox.p2.core.ProvisionException
        Throws:
        org.eclipse.equinox.p2.core.ProvisionException
      • internalStoreWithException

        private void internalStoreWithException()
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • load

        private void load()
                   throws org.eclipse.equinox.p2.core.ProvisionException
        Throws:
        org.eclipse.equinox.p2.core.ProvisionException
      • getInternalDescriptorFromLoadedDescriptor

        private ModuleArtifactRepository.ModuleArtifactDescriptor getInternalDescriptorFromLoadedDescriptor​(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor loadedDescriptor,
                                                                                                            java.io.File sourceFile)
                                                                                                     throws org.eclipse.equinox.p2.core.ProvisionException
        Throws:
        org.eclipse.equinox.p2.core.ProvisionException
      • failedReadException

        static org.eclipse.equinox.p2.core.ProvisionException failedReadException​(java.io.File sourceFile,
                                                                                  java.lang.String details,
                                                                                  java.lang.Exception exception)
      • isModifiable

        public boolean isModifiable()
        Specified by:
        isModifiable in interface org.eclipse.equinox.p2.repository.IRepository<org.eclipse.equinox.p2.metadata.IArtifactKey>
        Overrides:
        isModifiable in class org.eclipse.equinox.p2.repository.spi.AbstractRepository<org.eclipse.equinox.p2.metadata.IArtifactKey>
      • eq

        static <T> boolean eq​(T left,
                              T right)