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,

So to reiterate the use case:

What we are doing is analyzing artifacts in a repository and generate artifacts which contain the analysis results.

So for instance, we analyze artifact org.example:example:jar:1.0  with our analyzer and generate an analysis result artifact for that: org.example:example:zip:analysis.

The analysis is a time consuming process and, depending on user settings, might yield different artifacts(in content not coordinate) with each run.

The analysis artifact is then deployed to a repository.

Since the analysis is time consuming, we want to be able to skip the analysis. Thus, we need to be able to check whether the analysis artifact org.example:example:zip:analysis already exists in the repository.

Since the analysis might yield different results on different runs we also want to be able to replace existing analysis artifacts anyway, if they are old.

Sorry for the late response.

Thanks
Johannes
28. Februar 2013 12:13
Johannes Dorn wrote:

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

Sure, but for any such API to be of actual value, I need to understand the underlying use case first, hence my question.

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.

Could you elaborate some more on this process, especially the part about replacing artifacts which I assume is the reason why you want to check etags for outdated artifacts.

We are also checking repositories for transitive closures, whether all (transitive) dependencies can be resolved as this is important for our business logic.

Out of curiosity, does this closure check also include existence checks for metadata which would be required to resolve version ranges?


Benjamin
_______________________________________________
aether-users mailing list
aether-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aether-users
28. Februar 2013 08:01
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








25. Februar 2013 22:28
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
25. Februar 2013 11:49
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


--
Johannes Dorn

Codetrails UG (haftungsbeschränkt)
The knowledge transfer company

Robert-Bosch-Str. 7, 64293 Darmstadt
Tel: +49 6151 2767092
http://www.codetrails.com

Managing Director: Dr. Marcel Bruch
Handelsregister: Darmstadt HRB 91940



Back to the top