Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] Checking the existence of Artifacts

Hi again,

for now i've solved this by querying the lucene index of the repository.
This works reasonably well.

In the future, it would be great to have a dedicated API functionality for this.

We need this, as we are constantly creating new artifacts, as well as replace existing ones.
We do some complex calculations that create new artifacts, but in case one already exists, we want to skip this.

Related to that we'd also like to check the etag for existing artifacts to see, whether they are outdated and need to be replaced.

We are also checking repositories for transitive closures, whether all (transitive) dependencies can be resolved as this is important for our business logic.
Here we also need an existence check, so we can advise our users which artifacts he needs to place in the repository.

thanks again
Johannes





Am 25.02.2013 um 22:28 schrieb Benjamin Bentmann <bentmann@xxxxxxxxxxxx>:

> Johannes Dorn wrote:
> 
>> I would like to be able to check the existence of artifacts in repositories.
>> [...]
>> I've tried it with this snippet:
>> 
>> 	ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(coordinate, repos, new NullProgressMonitor());		
>> 	ArtifactDescriptorResult readArtifactDescriptor = repositorySystem.readArtifactDescriptor(session, request);		
> 
> Also keep in mind that the existence of an artifact descriptor doesn't say much about the actual artifact. For instance, some Sun/Oracle artifacts have only POMs in central but no JARs.
> 
>> Is there a way to ask a repository about the existence of an artifact?
> 
> Yes, but it requires you to reach out to a RepositoryConnector directly. Assuming you use org.sonatype.aether.*, you need to get hold of org.sonatype.aether.impl.RemoteRepositoryManager via dependency injection etc., call getRepositoryConnector() for each remote repository in question, and call RepositoryConnector.get() (and close()) for the artifacts to check for. The ArtifactDownload objects to pass in have a mutator called setExistenceCheck(), that's what you want.
> 
> May I ask what the use case behind all these checks is?
> 
> 
> Benjamin
> _______________________________________________
> aether-users mailing list
> aether-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aether-users



Back to the top