Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aether-users] How to retrieve the LATEST (also SNAPSHOT) version of a maven artifact using aether API?

I'm using eclipse.aether (version 1.0.0.v20140518) to programmatically fetch some maven artifacts from my repository. To do this I am using the following code:

Artifact artifact = new DefaultArtifact( artifactName );
ArtifactRequest artifactRequest = new ArtifactRequest().setArtifact( artifact );
repositorySystem.resolveArtifact(session, artifactRequest);

where artifactName is a String in the format "groupId:artifactId:version". When version is a fixed version (like in "org.myNamespace:myProject:1.0.0") everything works fine. Moreover I should be allowed also to replace the fixed version with "LATEST" (as in "org.myNamespace:myProject:LATEST") and in this case it should load the latest version of that artifact in my repository.

This also works but only partially, meaning that it never retrieves SNAPSHOTs artifacts, but only releases. This doesn't seem to be compliant with maven semantic as it is also described here How do I tell Maven to use the latest version of a dependency?

Am I doing something wrong? Is there a way to load the latest version of an artifact regardless if it is a release or a snapshot?

Thanks in advance for your help,
Mario

Back to the top