Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aether-users] Resolving test dependencies using aether

Hey Benjamin,

> As an alternative to the custom DependencySelector, you can replace the
> current call to collectRequest.setRoot() with an equivalent of the below
> call
>
>   collectRequest.setDependencies(
>       system.readArtifactDescriptor( session,
>           new ArtifactDescriptorRequest( artifact,
>              Arrays.asList( repo ), null ) ).getDependencies() );
>
> This basically mimics the way Maven resolves project dependencies.
>
> Aether stores files in the local repository. So once resolved, you have to
> copy them to the desired location yourself.

That's exactly what I was looking for.

One last thing we're trying to solve is to get Aether to download the
dependency itself. It also happens to be a test-jar artifact. We're
trying to resolve it like this:

Artifact artifact = new
DefaultArtifact("groupId","artifactId","tests","jars","version");
(or
Map<String, String> props = new HashMap<String, String>();
props.put("type","test-jar");
Artifact artifact = new DefaultArtifact("groupId:artifactId:version", props);)

ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.addRepository(repository);
ArtifactResult resolvedArtifact = system.resolveArtifact(session,
artifactRequest);
Artifact file = resolvedArtifact.getArtifact();

But that doesn't download the test jar. Do you happen to know how we
would get aether to resolve the test-jar? Again, we just need it to
download to the local repo and then pull it out of there, the way you
were saying.

Thank you for all your help Benjamin.

All the best,
--
Arthur Kalmenson



On Fri, Oct 21, 2011 at 5:19 PM, Benjamin Bentmann
<bentmann@xxxxxxxxxxxx> wrote:
> Arthur Kalmenson wrote:
>
>> Yes, that's what we did, we set a custom DependencySelector and now
>> it's transitively pulling down the test dependencies of each
>> dependency. That's actually not the behavior we want
>
> Frankly, I don't quite understand this statement. If your custom
> DependencySelector does not what you want, then implement it the way you
> want it. [0] gives some background on the graph processing.
>
>> The behavior that we're looking to
>> mimic with aether is really:
>>
>> mvn dependency:copy-dependencies
>
> As an alternative to the custom DependencySelector, you can replace the
> current call to collectRequest.setRoot() with an equivalent of the below
> call
>
>   collectRequest.setDependencies(
>       system.readArtifactDescriptor( session,
>           new ArtifactDescriptorRequest( artifact,
>              Arrays.asList( repo ), null ) ).getDependencies() );
>
> This basically mimics the way Maven resolves project dependencies.
>
> Aether stores files in the local repository. So once resolved, you have to
> copy them to the desired location yourself.
>
>
> Benjamin
>
>
> [0] https://docs.sonatype.org/display/AETHER/Introduction
> _______________________________________________
> aether-users mailing list
> aether-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aether-users
>


Back to the top