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

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


Back to the top