BTW, when dependencyArtifacts is populated is NOT based on the phase.
It's based on the @requiresDependencyResolution attribute of the invoked
plugins. It's probable that compile is the first phase in many projects
with a plugin tagged with @requiresDependencyResolution, but it is not
necessarily the case.
Also, I'm pretty sure Maven (not Plexus) is the one doing the resolving.
But that's neither here nor there.
Justin
On 4/19/10 2:46 PM, Pankaj Tandon wrote:
>
> I got this to work. Incase anyone else needs this...
>
> I was looking at the wrong property on mavenProject. Plexus does not
> populate dependencyArtifacts with the dependencies till the compile phase.
> However, the property mavenProject.dependencies is populated in the validate
> phase. It is populated even if some of the dependencies are not resolved.
>
> But an even better way to get at the dependencies is:
> Set<Artifact> dependentArtifactSet =
> mavenProject.createArtifacts(artifactFactory, null, null);
>
> HTH
>
>
> Pankaj Tandon wrote:
>>
>> Hello,
>>
>> I'm writing a plugin that needs to know the dependencies of the project it
>> is configured for, and if the dependencies are missing, do something about
>> it (like install the dependencies from another repo (with required
>> credentials of course)).
>>
>> To get a list of dependencies that a project uses, I decided to inject the
>> project via the @component annotation like so:
>> /** @parameter default-value="${project}" */
>> private org.apache.maven.project.MavenProject mavenProject;
>>
>> and then simply issue
>> Set<Artifact> dependencyArtifactSet =
>> mavenProject.getDependencyArtifacts();
>>
>> to get at the Set of dependencies.
>>
>> However, the dependencies are only injected into the project after the
>> compile phase of the default lifecycle. But more importantly, if a
>> dependency is missing, the build breaks with a "missing dependency..."
>> message BEFORE my plugin (that is bound to the compile phase) get's a
>> chance to process them.
>>
>> And if I bind my plugin to a phase prior to compile, the dependencies are
>> not even available to the project object because they are not yet injected
>> via Plexus.
>>
>> Of course, if there are no missing dependencies, then this arrangement
>> works just fine, by allowing me to process those dependencies in my
>> plugin. However, because there are no missing dependencies, there is no
>> problem and there is nothing to for me to process.
>>
>> So, how can I make this work such that I get a list of missing
>> dependencies within the plugin, BEFORE maven's artifactResolver punts and
>> complains of missing dependencies.
>>
>> Thanks a lot in advance,
>> Pankaj
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]