Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] Resolving version range for secondary artifact

Hi,

after debugging a while and a few hours of sleep:

It looks like that when resolving the version range with maven repositories, Aether only checks the remote metadata.xml files which versions have been declared there. In consequence it seems to be in my responsibility to check for existence of an appropriate model then.

Due to the lack of a index at the moment, I iterate over all version and try resolving the model file I'm looking for:

        Optional<VersionRangeResult> opt = resolveVersionRange(artifact);
        ArrayList<Version> versions = Lists.newArrayList(opt.get().getVersions());
        Collections.reverse(versions);
        for (Version v : versions) {
            try {
                Artifact query = artifact.setVersion(v.toString());
                // horribly inefficient but for the moment...
                resolve(query, new NullProgressMonitor());
                File l = location(query);
                if (l.exists()) {
                    log.debug("Found artifact " + artifact + " in version " + v);
                    return of(query);
                }
            } catch (DependencyResolutionException e) {
                // not found
                log.debug(e.getMessage());
            }
        }
        return absent();

Marcel

On 08.03.2012, at 01:06, Marcel Bruch wrote:

> Hi, 
> 
> a conceptual question:
> 
> I've primary artifacts (jar files) in many versions in my repository. Some of these artifacts have attached artifacts like sources.jar or  zip-files with additional information.
> 
> For instance, we have several versions of jface:
> 
>  org.eclipse.jface:org.eclipse.jface:3.0.0
>  org.eclipse.jface:org.eclipse.jface:3.6.0
>  org.eclipse.jface:org.eclipse.jface:3.7.1
> 
> but only for a few of them we have additional artifacts attached. For example we have on artifact "org.eclipse.jface:org.eclipse.jface:zip:model:3.0.0" but no "model zips" for any other version.
> 
> 
> Now, I'd like to issue a "highest-version" range query over the attached "model" artifact only. With the code below, I always get the highest version of the primary artifact, i.e, for the range request
> 
>  org.eclipse.jface:org.eclipse.jface:zip:models:[0,3.8.0)
> 
> it returns
> 
>  org.eclipse.jface:org.eclipse.jface:zip:models:3.7.1 
> 
> which does not exist. Any idea what I'm doing wrong here? Can I somehow limit the search to "zip:models" only?
> 
> 
> private Optional<VersionRangeResult> resolveVersionRange(Artifact a) {
>  VersionRangeRequest rangeRequest = new VersionRangeRequest().setArtifact(a).addRepository(remote);
>  try {
>    RepositorySystem system =...;
>    return of(system.resolveVersionRange(newSession(), rangeRequest));
>  } catch (Exception e) {
>    log.error("Failed to find highest version for artifact " + a, e);
>    return absent();
>  }
> }
> 
> 
> Thanks,
> Marcel
> 
> -- 
> Eclipse Code Recommenders:
> w www.eclipse.org/recommenders
> tw www.twitter.com/marcelbruch
> g+ www.gplus.to/marcelbruch
> 
> _______________________________________________
> aether-users mailing list
> aether-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aether-users

Thanks,
Marcel

-- 
Eclipse Code Recommenders:
 w www.eclipse.org/recommenders
 tw www.twitter.com/marcelbruch
 g+ www.gplus.to/marcelbruch



Back to the top