Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] How to download just the POM of an artifact?

Hi Benjamin,

> There's a ResolveArtifact class among the examples. Tweaking this to
> 
>   Artifact artifact = new DefaultArtifact(
> "org.sonatype.aether:aether-util:pom:1.13" );
>   RemoteRepository repo = Booter.newCentralRepository();
> 
>   ArtifactRequest artifactRequest = new ArtifactRequest();
>   artifactRequest.setArtifact( artifact );
>   artifactRequest.addRepository( repo );
>   ArtifactResult artifactResult = system.resolveArtifact( session,
> artifactRequest );
> 
>   artifact = artifactResult.getArtifact();
> 
>   System.out.println( artifact + " resolved to  " + artifact.getFile() );
> 
> works for me. So you might want to double-check why exactly your code
> didn't work, it's generally the right approach.

OK, we got it to work. Thank you.

The error was a really stupid one (and kind of surprising): The artifact
resolution works fine. However, a subsequent InstallRequest whose
artifact.getFile() was already in the local repo resulted in the the
file being truncated to zero bytes. (Yes, I know that installing
something you just resolved is redundant; the request came from an
install+deploy convenience method we had written.)

So, the real culprit (besides the one at the keyboard) was
system.install(..)'s handling of an Artifact already in the local repo.
Maybe this is worth guarding against with an IllegalArgumentException or so?

>> (preferably with Sonatype Aether 0.13.1, which I still have to use)?
> 
> Out of curiosity, why exactly are you bound to this old version?

Two reasons:

1.) We are using the org.eclipse.m2.maven.runtime bundle, which
conveniently contains things like the Nexus indexer as well. Not sure if
we could mix and match org.eclipse.m2.maven.runtime with
org.eclipse.aether, as we didn't investigate too deeply because of ...

2.) Eclipse Aether hasn't had a 1.0 release and as far as I know, a
Eclipse release-train project (FYI: we are Eclipse Code Recommenders)
can't depend on a pre-1.0 release, even if from org.eclipse.*. So, what
is your project for Aether 1.0? Will you make it in time for Luna?

Hope that explains things.

Andreas
-- 
Codetrails UG (haftungsbeschränkt)
The knowledge transfer company

Robert-Bosch-Str. 7, 64293 Darmstadt
Mobile: +49-170-811-3791
http://www.codetrails.com/

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


Back to the top