Class ModuleArtifactRepository
- java.lang.Object
-
- org.eclipse.core.runtime.PlatformObject
-
- org.eclipse.equinox.p2.repository.spi.AbstractRepository<org.eclipse.equinox.p2.metadata.IArtifactKey>
-
- org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository
-
- org.eclipse.tycho.repository.p2base.artifact.repository.AbstractArtifactRepository2
-
- org.eclipse.tycho.repository.p2base.artifact.repository.ArtifactRepositoryBaseImpl<ModuleArtifactRepository.ModuleArtifactDescriptor>
-
- org.eclipse.tycho.repository.module.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.)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ModuleArtifactRepository.ModuleArtifactComparableDescriptor
An artifact descriptor that can be compared withModuleArtifactRepository.ModuleArtifactDescriptor
.(package private) class
ModuleArtifactRepository.ModuleArtifactDescriptor
An artifact descriptor with Maven coordinates.
-
Field Summary
Fields Modifier and Type Field Description private ModuleArtifactMap
artifactsMap
private static GAV
DUMMY_GAV
private GAV
moduleGAV
private java.io.File
p2DataFile
static java.lang.String
REPOSITORY_TYPE
Type string for this repository type.-
Fields inherited from class org.eclipse.tycho.repository.p2base.artifact.repository.ArtifactRepositoryBaseImpl
descriptorsMap
-
-
Constructor Summary
Constructors Modifier Constructor Description private
ModuleArtifactRepository(org.eclipse.equinox.p2.core.IProvisioningAgent agent, java.io.File location, ModuleArtifactMap artifactsMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static boolean
canAttemptRead(java.io.File repositoryDir)
ModuleArtifactRepository.ModuleArtifactDescriptor
createArtifactDescriptor(org.eclipse.equinox.p2.metadata.IArtifactKey key)
org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor
createArtifactDescriptor(org.eclipse.equinox.p2.metadata.IArtifactKey key, WriteSessionContext writeSession)
private static ModuleArtifactMap
createArtifactLocationMap(java.io.File repositoryDir)
static ModuleArtifactRepository
createInstance(org.eclipse.equinox.p2.core.IProvisioningAgent agent, java.io.File repositoryDir)
(package private) static org.eclipse.equinox.p2.core.ProvisionException
failedReadException(java.io.File sourceFile, java.lang.String details, java.lang.Exception exception)
ModuleArtifactMap
getArtifactsMap()
protected org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor
getComparableDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Returns anIArtifactDescriptor
instance which is comparable to the artifact descriptors stored in the index (i.e.protected ModuleArtifactRepository.ModuleArtifactDescriptor
getInternalDescriptorForAdding(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Returns an artifact descriptor of the internal descriptor typeArtifactDescriptorT
which may be added to the index.private ModuleArtifactRepository.ModuleArtifactDescriptor
getInternalDescriptorFromLoadedDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor loadedDescriptor, java.io.File sourceFile)
protected java.io.File
internalGetArtifactStorageLocation(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Returns the file system location where the given artifact is or would be stored.protected void
internalStore(org.eclipse.core.runtime.IProgressMonitor monitor)
Persists the index of this repository.private void
internalStoreWithException()
boolean
isFileAlreadyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey artifactKey)
boolean
isModifiable()
private void
load()
IArtifactSink
newAddingArtifactSink(org.eclipse.equinox.p2.metadata.IArtifactKey key, WriteSessionContext writeSession)
private static MavenRepositoryCoordinates
readMavenCoordinates(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
static ModuleArtifactRepository
restoreInstance(org.eclipse.equinox.p2.core.IProvisioningAgent agent, java.io.File repositoryDir)
void
setGAV(java.lang.String groupId, java.lang.String artifactId, java.lang.String version)
private void
storeOrProvisioningException()
-
Methods inherited from class org.eclipse.tycho.repository.p2base.artifact.repository.ArtifactRepositoryBaseImpl
contains, contains, descriptorQueryable, flattenedValues, getArtifact, getArtifact, getArtifactDescriptors, getArtifactFile, getArtifactFile, getRawArtifact, internalAddDescriptor, internalAddInternalDescriptor, internalNewAddingArtifactSink, internalRemoveAllDescriptors, internalRemoveDescriptor, internalRemoveDescriptors, internalRemoveDescriptors, internalRemoveDescriptors, newAddingArtifactSink, newAddingRawArtifactSink, query
-
Methods inherited from class org.eclipse.tycho.repository.p2base.artifact.repository.AbstractArtifactRepository2
addDescriptor, addDescriptor, addDescriptors, addDescriptors, getArtifacts, getOutputStream, getRawArtifact, isFatal, removeAll, removeAll, removeDescriptor, removeDescriptor, removeDescriptor, removeDescriptor, removeDescriptors, removeDescriptors, removeDescriptors, removeDescriptors, setStatusOnStreamIfPossible
-
Methods inherited from class org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository
createArtifactKey, equals, executeBatch, hashCode
-
Methods inherited from class org.eclipse.equinox.p2.repository.spi.AbstractRepository
assertModifiable, getDescription, getLocation, getName, getProperties, getProperty, getProvider, getProvisioningAgent, getType, getVersion, setDescription, setLocation, setName, setProperties, setProperty, setProperty, setProvider, setType, setVersion
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.equinox.p2.repository.artifact.IArtifactRepository
addDescriptor, addDescriptor, addDescriptors, addDescriptors, createArtifactKey, executeBatch, getArtifacts, getOutputStream, getRawArtifact, removeAll, removeAll, removeDescriptor, removeDescriptor, removeDescriptor, removeDescriptor, removeDescriptors, removeDescriptors, removeDescriptors, removeDescriptors
-
-
-
-
Field Detail
-
REPOSITORY_TYPE
public static final java.lang.String REPOSITORY_TYPE
Type string for this repository type. This value needs to be passed toIArtifactRepositoryManager.createRepository(URI, String, String, Map)
in order to create a repository of typeModuleArtifactRepository
.- See Also:
- Constant Field Values
-
DUMMY_GAV
private static final GAV DUMMY_GAV
-
p2DataFile
private final java.io.File p2DataFile
-
artifactsMap
private final ModuleArtifactMap artifactsMap
-
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)
-
getArtifactsMap
public ModuleArtifactMap getArtifactsMap()
-
internalGetArtifactStorageLocation
protected java.io.File internalGetArtifactStorageLocation(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)
Description copied from class:ArtifactRepositoryBaseImpl
Returns the file system location where the given artifact is or would be stored. UnlikeArtifactRepositoryBaseImpl.getArtifactFile(IArtifactDescriptor)
, this method does not check if the given artifact exists in the repository and never returnsnull
.This method may be called by any API method for reading or writing artifacts.
-
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 anIArtifactDescriptor
instance which is comparable to the artifact descriptors stored in the index (i.e. theArtifactRepositoryBaseImpl.descriptorsMap
member). A valid implementation is to convert the argument to the internal descriptor typeArtifactDescriptorT
, but this is not a requirement. This method should be implemented in a way so that callingdescriptors.contains(getComparableDescriptor(foreignDescriptor))
with a descriptor from a foreign artifact repository returnstrue
if and only if copying that foreign artifact to this repository withAbstractArtifactRepository2.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 classArtifactRepositoryBaseImpl<ModuleArtifactRepository.ModuleArtifactDescriptor>
- Parameters:
descriptor
- AnIArtifactDescriptor
from any artifact repository.
-
getInternalDescriptorForAdding
protected ModuleArtifactRepository.ModuleArtifactDescriptor getInternalDescriptorForAdding(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor) throws java.lang.IllegalArgumentException
Description copied from class:ArtifactRepositoryBaseImpl
Returns an artifact descriptor of the internal descriptor typeArtifactDescriptorT
which may be added to the index. Implementations may require that the descriptor argument is a descriptor instance created by this repository – seeAbstractArtifactRepository.createArtifactDescriptor(IArtifactKey)
.This method is called by methods that add entries to the index, i.e. from
ArtifactRepositoryBaseImpl.newAddingArtifactSink(IArtifactKey)
.- Specified by:
getInternalDescriptorForAdding
in classArtifactRepositoryBaseImpl<ModuleArtifactRepository.ModuleArtifactDescriptor>
- Parameters:
descriptor
- AnIArtifactDescriptor
instance- Throws:
java.lang.IllegalArgumentException
- if the provided descriptor cannot be added
-
createArtifactDescriptor
public ModuleArtifactRepository.ModuleArtifactDescriptor createArtifactDescriptor(org.eclipse.equinox.p2.metadata.IArtifactKey key)
- Specified by:
createArtifactDescriptor
in interfaceorg.eclipse.equinox.p2.repository.artifact.IArtifactRepository
- Overrides:
createArtifactDescriptor
in classorg.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
-
internalStore
protected void internalStore(org.eclipse.core.runtime.IProgressMonitor monitor)
Description copied from class:ArtifactRepositoryBaseImpl
Persists the index of this repository.This method is called after every (bulk) change to the index.
- Overrides:
internalStore
in classArtifactRepositoryBaseImpl<ModuleArtifactRepository.ModuleArtifactDescriptor>
-
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 interfaceorg.eclipse.equinox.p2.repository.IRepository<org.eclipse.equinox.p2.metadata.IArtifactKey>
- Overrides:
isModifiable
in classorg.eclipse.equinox.p2.repository.spi.AbstractRepository<org.eclipse.equinox.p2.metadata.IArtifactKey>
-
isFileAlreadyAvailable
public boolean isFileAlreadyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey artifactKey)
-
-