Ok, I guess I'm still not used to the "maven way" :-) The code in 
ResolvePluginsMojo was confusing to me until I walked up the class 
hierarchy. Here is what I came up with:

    /**
     * Used to look up Artifacts in the remote repository.
     * 
     * @parameter 
expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
     * @required
     * @readonly
     */
    protected org.apache.maven.artifact.factory.ArtifactFactory factory;

    /**
     * Used to look up Artifacts in the remote repository.
     * 
     * @parameter 
expression="${component.org.apache.maven.artifact.resolver.ArtifactResolver}"
     * @required
     * @readonly
     */
    protected org.apache.maven.artifact.resolver.ArtifactResolver 
resolver;

    /**
     * Location of the local repository.
     * 
     * @parameter expression="${localRepository}"
     * @readonly
     * @required
     */
    protected org.apache.maven.artifact.repository.ArtifactRepository 
local;

    /**
     * List of Remote Repositories used by the resolver
     * 
     * @parameter expression="${project.remoteArtifactRepositories}"
     * @readonly
     * @required
     */
    protected java.util.List remoteRepos;

        private File getArtifactFile(String groupId, String artifactId, 
String version) throws MavenReportException
        {
                // Ask maven for the correct path to statcvs
                VersionRange range = VersionRange.createFromVersion 
(version);
                Artifact statcvs = factory.createPluginArtifact(groupId, 
artifactId, range);
                try {
                        resolver.resolve(statcvs, remoteRepos, local);
                } catch (ArtifactResolutionException e) {
                        throw new MavenReportException ("Error resolving 
artifact "+statcvs, e);
                } catch (ArtifactNotFoundException e) {
                        throw new MavenReportException ("Error resolving 
artifact "+statcvs, e);
                }
 
                return statcvs.getFile();
        }

Is this code correct?

Now, it would be great if I could access my plugin's POM (*not* the POM of 
the current project) to load the version number from there. Is there a 
way? 

I guess I could use a filter :-/

Regards,

-- 
Aaron Digulla

[EMAIL PROTECTED] schrieb am 13.10.2006 11:11:39:

> "Dan Tran" <[EMAIL PROTECTED]> schrieb am 12.10.2006 12:14:47:
> 
> > > How do I determine the absolute path for a JAR in the repository?
> > 
> 
http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-dependency-plugin
> > 
> > Look for Copy Artifact/Dependency, etc
> 
> That's only for project dependencies. I need to find the dependencies of 

> myself (where self == report plugin)!
> 
> I tried to find myself in getProject().getReportArtifactMap() which 
works 
> but the Artifact returned contains almost no information (getFile() is 
> null, for example, the list of dependencies is empty, the metadata is 
> empty, ...)
> 
> The next idea was to browse the Repositories but how do I ask a 
repository 
> for an artifact? (Note: this artifact is *not* in the dependency list of 

> the current POM!)
> 
> Regards,
> 
> -- 
> Aaron Digulla
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to