Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aether-users] Resolving dependencies from local pom.xml

Hi,

I'm using a piece of code similar to the example provided on the wiki [1] to resolve the dependencies within a Maven plugin.
My goal is to resolve the dependencies of the current project where the Maven plugin has been called from. 

I experience 2 different behaviors, depending on the environment:
1) If an artifact of the current project already exists (either on Nexus or in the local repository), the dependencies from the remote pom.xml will be resolved.
2) If the environment is clean, the dependencies will come from the local pom.xml, as I expect.

In order to fall in the first case, a deployed SNAPSHOT version on Nexus is enough.

Is there a way to take into account only the local pom.xml of the current project?

For completeness, here how the root is set from the mojo:
/**
* The project's remote repositories to use for the resolution.
* @parameter default-value="${project.remoteProjectRepositories}"
* @readonly
*/
private List<RemoteRepository> remoteRepos;

/**
* @parameter default-value="${project}"
* @readonly
*/
private MavenProject project;

...

Dependency dependency = new Dependency(new DefaultArtifact(project.getArtifact().toString()), COMPILE_SCOPE);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(dependency);
collectRequest.setRepositories(remoteRepos);

Cheers,
Jérémy


[1] https://docs.sonatype.org/display/AETHER/Home#Home-ResolvingDependencies

Back to the top