Skip to main content

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

Hi,

I would like to be able to check the existence of artifacts in repositories.

Here are two examples i need the check to be able to do:

1. Artifact's pom specifies a non-existent repository and the artifact .jar was manually placed next to it. Then the check should return true.

2. If artifact exists in local cache but not in the questioned (remote) repository, check should return false.


I've tried it with this snippet: 

	ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(coordinate, repos, new NullProgressMonitor());		
	ArtifactDescriptorResult readArtifactDescriptor = repositorySystem.readArtifactDescriptor(session, request);		
	ArtifactRepository repository = readArtifactDescriptor.getRepository();
	return repository != null;

but this doesn't work with the first example.

The other way i've tried is to try and resolve the artifact and return false if there is an ArtifactResolutionException.
This doesn't work with the second example(which wouldn't be too bad) but also downloads every existing artifact. This is bad, since the check is performed on a potentially huge number of artifacts on remote repositories.

Is there a way to ask a repository about the existence of an artifact?


Thanks
Johannes

Back to the top