You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Roland Asmann <Ro...@cfc.at> on 2007/06/04 15:14:04 UTC

Programmatically finding dependencies

Hi all,

I'm writing a plugin here and want to figure out how to get hold of the 
dependencies as defined in the POM for my plugin.
I'm currently using the ArtifactCollector, but it resolves transitive 
dependencies as well... I only want to have the dependencies that are 
DIRECTLY defined inside the POM-file.

Any hints on how to do this?

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Programmatically finding dependencies

Posted by Roland Asmann <Ro...@cfc.at>.
For your first question (other mail): I'm running on the 2.0 API, although I 
will probably switch along the way... Thanks for the info on the 
method-signature!

> this.project.getRemoteArtifact.Repositories()
> this.localRepository
>
> How did u retrieve this informations?

As for the other 2 questions, here's a snippet of code:

    /**
     * @parameter expression="${project}"
     * @readonly
     * @required
     */
    protected MavenProject project;

    /**
     * @parameter expression="${localRepository}"
     * @required
     * @readonly
     */
    private ArtifactRepository localRepository;

The project has a method 'getRemoteArtifactRepositories()' (looks like a 
copy-paste failure in your text below!).

Beware though, I am currently using 2.0 for all APIs, so if any signatures 
have changed, you might not get everything to work!

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Programmatically finding dependencies

Posted by CasMeiron <ca...@gmail.com>.
this.project.getRemoteArtifact.Repositories()
this.localRepository

How did u retrieve this informations?

Tkz.

On 6/5/07, Roland Asmann <Ro...@cfc.at> wrote:
>
> Thanks for the numerous replies.
>
> > > > > ${project.dependencies} ?
>
> The ${project.dependencies} is not the correct one, since it gives me the
> dependencies of the project, not the plugin! Also, it resolves the
> dependencies transitively!
>
> > ArtifactoryFactory : interface
> > ArtifactResolver : interface
> >
> > Where can we find the implementations? I already have a list of
> > dependencies, just need resolve the full path for each dependency.
> >
> > > Use the information in the dependency list and an ArtifactFactory to
> > > create
> > > an Artifact with , then use an ArtifactResolver to resolve them fully.
> > > Afterwards, you can call getFile(), to get the File objet.
>
> When using those interfaces, add something similar to these lines in your
> MOJO:
>
>     /**
>      * @component role="
> org.apache.maven.artifact.resolver.ArtifactResolver"
>      * @required
>      * @readonly
>      */
>     private ArtifactResolver artifactResolver;
>
> Now, you can use
>
> artifactResolver.resolve(artifact)
>
> for you artifact (if it has not been resolved already), after which you
> can
> ask the artifact
>
> artifact.getFile()
>
> which will give you the full path to the JAR/POM/whatever file of this
> artifact.
>
>
>
> For my situation though (dependencies of the plugin), I use the following
> code:
>
> for (Object object : this.project.getPluginArtifacts()) {
>     Artifact artifact = (Artifact) object;
>     if ("my.group.id".equals(artifact.getGroupId())
> && "myArtifactId".equals(artifact.getArtifactId())) {
>         for (Object object2 : this.artifactMetadataSource.retrieve
> (artifact,
> this.localRepository,
> this.project.getRemoteArtifactRepositories()).getArtifacts()) {
>             Artifact artifact2 = (Artifact) object2;
>             this.artifactResolver.resolve(artifact2,
> this.project.getRemoteArtifactRepositories(), this.localRepository);
>             JarFile jarFile = new JarFile(artifact2.getFile());
>             JarEntry workflow = null;
>             for (Enumeration<JarEntry> jarEntries = jarFile.entries();
> workflow == null && jarEntries.hasMoreElements();) {
>                 JarEntry jarEntry = jarEntries.nextElement();
>                 if (jarEntry.getName() != null &&
> jarEntry.getName().endsWith("filename.extension")) {
>                     workflow = jarEntry;
>                 }
>             }
>             if (workflow != null) {
>                 workflowFiles.add(workflow.getName());
>             }
>         }
>     }
> }
>
> In short, this code runs through the plugins until it finds the one I'm
> looking for ("my.group.id" & "myArtifactId"). It then retrieves this
> artifact
> from the repository and gets its dependencies.
> Those are resolved (to make sure all properties have been initialized --
> eg
> fileName doesn't work without it) and opened as JAR-files (atm I'm sure
> they
> are JARs, but need to change this code to make sure it doesn't fail if
> they're not).
> I then iterate over the JAR to look for a specific file ("
> filename.extension")
> and save the full names of the entry in a Map.
>
> This works like a charm for me, you just need to make sure you add all the
> right components in the MOJO.
>
> If anybody needs some more info/help, feel free to ask!
>
> --
> Roland Asmann
>
> CFC Informationssysteme Entwicklungsgesellschaft m.b.H
> Bäckerstrasse 1/2/7
> A-1010 Wien
> FN 266155f, Handelsgericht Wien
>
> Tel.: +43/1/513 88 77 - 27
> Fax.: +43/1/513 88 62
> Email: Roland.Asmann@cfc.at
> Web: www.cfc.at
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Paulo Cesar Silva Reis
-------------------------------
Powered by GMAIL

Re: Programmatically finding dependencies

Posted by CasMeiron <ca...@gmail.com>.
dammit google shortkeys, sry:

void resolve( Artifact, List, ArtifactRepository )
void resolve( Set, Artifact, List, ArtifactRepository )

Im using maven 2.0.6 api.

tkz.

On 6/5/07, CasMeiron <ca...@gmail.com> wrote:
>
> Tkz for the answer.
> I tried what u said, but my ArtifactManager doenst have the "resolve"
> method with one parameter, look:
>
> void resolve( Artifact, List
>
> On 6/5/07, Roland Asmann <Ro...@cfc.at> wrote:
> >
> > Thanks for the numerous replies.
> >
> > > > > > ${project.dependencies} ?
> >
> > The ${project.dependencies} is not the correct one, since it gives me
> > the
> > dependencies of the project, not the plugin! Also, it resolves the
> > dependencies transitively!
> >
> > > ArtifactoryFactory : interface
> > > ArtifactResolver : interface
> > >
> > > Where can we find the implementations? I already have a list of
> > > dependencies, just need resolve the full path for each dependency.
> > >
> > > > Use the information in the dependency list and an ArtifactFactory to
> > > > create
> > > > an Artifact with , then use an ArtifactResolver to resolve them
> > fully.
> > > > Afterwards, you can call getFile(), to get the File objet.
> >
> > When using those interfaces, add something similar to these lines in
> > your
> > MOJO:
> >
> >     /**
> >      * @component role="
> > org.apache.maven.artifact.resolver.ArtifactResolver"
> >      * @required
> >      * @readonly
> >      */
> >     private ArtifactResolver artifactResolver;
> >
> > Now, you can use
> >
> > artifactResolver.resolve(artifact)
> >
> > for you artifact (if it has not been resolved already), after which you
> > can
> > ask the artifact
> >
> > artifact.getFile()
> >
> > which will give you the full path to the JAR/POM/whatever file of this
> > artifact.
> >
> >
> >
> > For my situation though (dependencies of the plugin), I use the
> > following
> > code:
> >
> > for (Object object : this.project.getPluginArtifacts()) {
> >     Artifact artifact = (Artifact) object;
> >     if ("my.group.id".equals(artifact.getGroupId())
> > && "myArtifactId".equals( artifact.getArtifactId())) {
> >         for (Object object2 : this.artifactMetadataSource.retrieve
> > (artifact,
> > this.localRepository,
> > this.project.getRemoteArtifactRepositories()).getArtifacts()) {
> >             Artifact artifact2 = (Artifact) object2;
> >             this.artifactResolver.resolve(artifact2,
> > this.project.getRemoteArtifactRepositories(), this.localRepository);
> >             JarFile jarFile = new JarFile(artifact2.getFile());
> >             JarEntry workflow = null;
> >             for (Enumeration<JarEntry> jarEntries = jarFile.entries();
> > workflow == null && jarEntries.hasMoreElements();) {
> >                 JarEntry jarEntry = jarEntries.nextElement();
> >                 if ( jarEntry.getName() != null &&
> > jarEntry.getName().endsWith("filename.extension")) {
> >                     workflow = jarEntry;
> >                 }
> >             }
> >             if (workflow != null) {
> >                 workflowFiles.add(workflow.getName());
> >             }
> >         }
> >     }
> > }
> >
> > In short, this code runs through the plugins until it finds the one I'm
> > looking for (" my.group.id" & "myArtifactId"). It then retrieves this
> > artifact
> > from the repository and gets its dependencies.
> > Those are resolved (to make sure all properties have been initialized --
> > eg
> > fileName doesn't work without it) and opened as JAR-files (atm I'm sure
> > they
> > are JARs, but need to change this code to make sure it doesn't fail if
> > they're not).
> > I then iterate over the JAR to look for a specific file ("
> > filename.extension")
> > and save the full names of the entry in a Map.
> >
> > This works like a charm for me, you just need to make sure you add all
> > the
> > right components in the MOJO.
> >
> > If anybody needs some more info/help, feel free to ask!
> >
> > --
> > Roland Asmann
> >
> > CFC Informationssysteme Entwicklungsgesellschaft m.b.H
> > Bäckerstrasse 1/2/7
> > A-1010 Wien
> > FN 266155f, Handelsgericht Wien
> >
> > Tel.: +43/1/513 88 77 - 27
> > Fax.: +43/1/513 88 62
> > Email: Roland.Asmann@cfc.at
> > Web: www.cfc.at
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> Paulo Cesar Silva Reis
> -------------------------------
> Powered by GMAIL
>



-- 
Paulo Cesar Silva Reis
-------------------------------
Powered by GMAIL

Re: Programmatically finding dependencies

Posted by CasMeiron <ca...@gmail.com>.
Tkz for the answer.
I tried what u said, but my ArtifactManager doenst have the "resolve" method
with one parameter, look:

void resolve( Artifact, List

On 6/5/07, Roland Asmann <Ro...@cfc.at> wrote:
>
> Thanks for the numerous replies.
>
> > > > > ${project.dependencies} ?
>
> The ${project.dependencies} is not the correct one, since it gives me the
> dependencies of the project, not the plugin! Also, it resolves the
> dependencies transitively!
>
> > ArtifactoryFactory : interface
> > ArtifactResolver : interface
> >
> > Where can we find the implementations? I already have a list of
> > dependencies, just need resolve the full path for each dependency.
> >
> > > Use the information in the dependency list and an ArtifactFactory to
> > > create
> > > an Artifact with , then use an ArtifactResolver to resolve them fully.
> > > Afterwards, you can call getFile(), to get the File objet.
>
> When using those interfaces, add something similar to these lines in your
> MOJO:
>
>     /**
>      * @component role="
> org.apache.maven.artifact.resolver.ArtifactResolver"
>      * @required
>      * @readonly
>      */
>     private ArtifactResolver artifactResolver;
>
> Now, you can use
>
> artifactResolver.resolve(artifact)
>
> for you artifact (if it has not been resolved already), after which you
> can
> ask the artifact
>
> artifact.getFile()
>
> which will give you the full path to the JAR/POM/whatever file of this
> artifact.
>
>
>
> For my situation though (dependencies of the plugin), I use the following
> code:
>
> for (Object object : this.project.getPluginArtifacts()) {
>     Artifact artifact = (Artifact) object;
>     if ("my.group.id".equals(artifact.getGroupId())
> && "myArtifactId".equals(artifact.getArtifactId())) {
>         for (Object object2 : this.artifactMetadataSource.retrieve
> (artifact,
> this.localRepository,
> this.project.getRemoteArtifactRepositories()).getArtifacts()) {
>             Artifact artifact2 = (Artifact) object2;
>             this.artifactResolver.resolve(artifact2,
> this.project.getRemoteArtifactRepositories(), this.localRepository);
>             JarFile jarFile = new JarFile(artifact2.getFile());
>             JarEntry workflow = null;
>             for (Enumeration<JarEntry> jarEntries = jarFile.entries();
> workflow == null && jarEntries.hasMoreElements();) {
>                 JarEntry jarEntry = jarEntries.nextElement();
>                 if (jarEntry.getName() != null &&
> jarEntry.getName().endsWith("filename.extension")) {
>                     workflow = jarEntry;
>                 }
>             }
>             if (workflow != null) {
>                 workflowFiles.add(workflow.getName());
>             }
>         }
>     }
> }
>
> In short, this code runs through the plugins until it finds the one I'm
> looking for ("my.group.id" & "myArtifactId"). It then retrieves this
> artifact
> from the repository and gets its dependencies.
> Those are resolved (to make sure all properties have been initialized --
> eg
> fileName doesn't work without it) and opened as JAR-files (atm I'm sure
> they
> are JARs, but need to change this code to make sure it doesn't fail if
> they're not).
> I then iterate over the JAR to look for a specific file ("
> filename.extension")
> and save the full names of the entry in a Map.
>
> This works like a charm for me, you just need to make sure you add all the
> right components in the MOJO.
>
> If anybody needs some more info/help, feel free to ask!
>
> --
> Roland Asmann
>
> CFC Informationssysteme Entwicklungsgesellschaft m.b.H
> Bäckerstrasse 1/2/7
> A-1010 Wien
> FN 266155f, Handelsgericht Wien
>
> Tel.: +43/1/513 88 77 - 27
> Fax.: +43/1/513 88 62
> Email: Roland.Asmann@cfc.at
> Web: www.cfc.at
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Paulo Cesar Silva Reis
-------------------------------
Powered by GMAIL

Re: Programmatically finding dependencies

Posted by Roland Asmann <Ro...@cfc.at>.
Thanks for the numerous replies.

> > > > ${project.dependencies} ?

The ${project.dependencies} is not the correct one, since it gives me the 
dependencies of the project, not the plugin! Also, it resolves the 
dependencies transitively!

> ArtifactoryFactory : interface
> ArtifactResolver : interface
>
> Where can we find the implementations? I already have a list of
> dependencies, just need resolve the full path for each dependency.
>
> > Use the information in the dependency list and an ArtifactFactory to
> > create
> > an Artifact with , then use an ArtifactResolver to resolve them fully.
> > Afterwards, you can call getFile(), to get the File objet.

When using those interfaces, add something similar to these lines in your 
MOJO:

    /**
     * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
     * @required
     * @readonly
     */
    private ArtifactResolver artifactResolver;

Now, you can use

artifactResolver.resolve(artifact)

for you artifact (if it has not been resolved already), after which you can 
ask the artifact

artifact.getFile()

which will give you the full path to the JAR/POM/whatever file of this 
artifact.



For my situation though (dependencies of the plugin), I use the following 
code:

for (Object object : this.project.getPluginArtifacts()) {
    Artifact artifact = (Artifact) object;
    if ("my.group.id".equals(artifact.getGroupId()) 
&& "myArtifactId".equals(artifact.getArtifactId())) {
        for (Object object2 : this.artifactMetadataSource.retrieve(artifact, 
this.localRepository, 
this.project.getRemoteArtifactRepositories()).getArtifacts()) {
            Artifact artifact2 = (Artifact) object2;
            this.artifactResolver.resolve(artifact2, 
this.project.getRemoteArtifactRepositories(), this.localRepository);
            JarFile jarFile = new JarFile(artifact2.getFile());
            JarEntry workflow = null;
            for (Enumeration<JarEntry> jarEntries = jarFile.entries(); 
workflow == null && jarEntries.hasMoreElements();) {
                JarEntry jarEntry = jarEntries.nextElement();
                if (jarEntry.getName() != null && 
jarEntry.getName().endsWith("filename.extension")) {
                    workflow = jarEntry;
                }
            }
            if (workflow != null) {
                workflowFiles.add(workflow.getName());
            }
        }
    }
}

In short, this code runs through the plugins until it finds the one I'm 
looking for ("my.group.id" & "myArtifactId"). It then retrieves this artifact 
from the repository and gets its dependencies.
Those are resolved (to make sure all properties have been initialized -- eg 
fileName doesn't work without it) and opened as JAR-files (atm I'm sure they 
are JARs, but need to change this code to make sure it doesn't fail if 
they're not).
I then iterate over the JAR to look for a specific file ("filename.extension") 
and save the full names of the entry in a Map.

This works like a charm for me, you just need to make sure you add all the 
right components in the MOJO.

If anybody needs some more info/help, feel free to ask!

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Programmatically finding dependencies

Posted by Jason van Zyl <ja...@maven.org>.
John might have a recommendation from an API he cleaned up. I don't  
recommend anyone use the current APIs for artifact resolution.

On 5 Jun 07, at 12:11 PM 5 Jun 07, Jo Vandermeeren wrote:

> On 6/5/07, CasMeiron <ca...@gmail.com> wrote:
>>
>> ArtifactoryFactory : interface
>> ArtifactResolver : interface
>>
>> Where can we find the implementations? I already have a list of
>> dependencies, just need resolve the full path for each dependency.
>>
>
>
> Instances of these interfaces can be injected into your mojo as plexus
> components.
> Just tag them with javadoc annotations and they will be injected,  
> like this:
>
>    /**
>     * @component
>     */
>    private ArtifactFactory artifactFactory;
>    /**
>     * @component
>     */
>    private ArtifactResolver artifactResolver;
>
> Cheers
> Jo

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder and PMC Chair, Apache Maven
jason at sonatype dot com
----------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Programmatically finding dependencies

Posted by Jo Vandermeeren <jo...@gmail.com>.
On 6/5/07, CasMeiron <ca...@gmail.com> wrote:
>
> ArtifactoryFactory : interface
> ArtifactResolver : interface
>
> Where can we find the implementations? I already have a list of
> dependencies, just need resolve the full path for each dependency.
>


Instances of these interfaces can be injected into your mojo as plexus
components.
Just tag them with javadoc annotations and they will be injected, like this:

    /**
     * @component
     */
    private ArtifactFactory artifactFactory;
    /**
     * @component
     */
    private ArtifactResolver artifactResolver;

Cheers
Jo

Re: Programmatically finding dependencies

Posted by CasMeiron <ca...@gmail.com>.
ArtifactoryFactory : interface
ArtifactResolver : interface

Where can we find the implementations? I already have a list of
dependencies, just need resolve the full path for each dependency.

On 6/5/07, Jo Vandermeeren <jo...@gmail.com> wrote:
>
> Use the information in the dependency list and an ArtifactFactory to
> create
> an Artifact with , then use an ArtifactResolver to resolve them fully.
> Afterwards, you can call getFile(), to get the File objet.
>
> Cheers
> Jo
>
> On 6/4/07, CasMeiron <ca...@gmail.com> wrote:
> >
> > We can retrieve all dependencies in project using el ${
> > project.dependencies},
> > but how can we get the full path of each dependency? (for classpath
> > issues).
> >
> > On 6/4/07, Mark Hobson <ma...@gmail.com> wrote:
> > >
> > > On 04/06/07, Roland Asmann <Ro...@cfc.at> wrote:
> > > > Hi all,
> > > >
> > > > I'm writing a plugin here and want to figure out how to get hold of
> > the
> > > > dependencies as defined in the POM for my plugin.
> > > > I'm currently using the ArtifactCollector, but it resolves
> transitive
> > > > dependencies as well... I only want to have the dependencies that
> are
> > > > DIRECTLY defined inside the POM-file.
> > > >
> > > > Any hints on how to do this?
> > >
> > > ${project.dependencies} ?
> > >
> > > Mark
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >
> >
> > --
> > Paulo Cesar Silva Reis
> > -------------------------------
> > Powered by GMAIL
> >
>



-- 
Paulo Cesar Silva Reis
-------------------------------
Powered by GMAIL

Re: Programmatically finding dependencies

Posted by Jo Vandermeeren <jo...@gmail.com>.
Use the information in the dependency list and an ArtifactFactory to create
an Artifact with , then use an ArtifactResolver to resolve them fully.
Afterwards, you can call getFile(), to get the File objet.

Cheers
Jo

On 6/4/07, CasMeiron <ca...@gmail.com> wrote:
>
> We can retrieve all dependencies in project using el ${
> project.dependencies},
> but how can we get the full path of each dependency? (for classpath
> issues).
>
> On 6/4/07, Mark Hobson <ma...@gmail.com> wrote:
> >
> > On 04/06/07, Roland Asmann <Ro...@cfc.at> wrote:
> > > Hi all,
> > >
> > > I'm writing a plugin here and want to figure out how to get hold of
> the
> > > dependencies as defined in the POM for my plugin.
> > > I'm currently using the ArtifactCollector, but it resolves transitive
> > > dependencies as well... I only want to have the dependencies that are
> > > DIRECTLY defined inside the POM-file.
> > >
> > > Any hints on how to do this?
> >
> > ${project.dependencies} ?
> >
> > Mark
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> Paulo Cesar Silva Reis
> -------------------------------
> Powered by GMAIL
>

Re: Programmatically finding dependencies

Posted by CasMeiron <ca...@gmail.com>.
We can retrieve all dependencies in project using el ${project.dependencies},
but how can we get the full path of each dependency? (for classpath issues).

On 6/4/07, Mark Hobson <ma...@gmail.com> wrote:
>
> On 04/06/07, Roland Asmann <Ro...@cfc.at> wrote:
> > Hi all,
> >
> > I'm writing a plugin here and want to figure out how to get hold of the
> > dependencies as defined in the POM for my plugin.
> > I'm currently using the ArtifactCollector, but it resolves transitive
> > dependencies as well... I only want to have the dependencies that are
> > DIRECTLY defined inside the POM-file.
> >
> > Any hints on how to do this?
>
> ${project.dependencies} ?
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Paulo Cesar Silva Reis
-------------------------------
Powered by GMAIL

Re: Programmatically finding dependencies

Posted by Mark Hobson <ma...@gmail.com>.
On 04/06/07, Roland Asmann <Ro...@cfc.at> wrote:
> Hi all,
>
> I'm writing a plugin here and want to figure out how to get hold of the
> dependencies as defined in the POM for my plugin.
> I'm currently using the ArtifactCollector, but it resolves transitive
> dependencies as well... I only want to have the dependencies that are
> DIRECTLY defined inside the POM-file.
>
> Any hints on how to do this?

${project.dependencies} ?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Programmatically finding dependencies

Posted by Jo Vandermeeren <jo...@gmail.com>.
Hi Roland,

Hmm..
I guess you could let the dependencies get resolved transitively, and then
parse the pom.xml yourself to get a more restrictive list of dependencies.
Dependency details could have been defined at a parent level, so enrich the
data in your parsed list with the information that is available in the
artifact collector, and you're there.

The maven project reader that is available won't do you any good either,
because it also resolves the parent poms.

Cheers
Jo


On 6/4/07, Roland Asmann <Ro...@cfc.at> wrote:
>
> Hi all,
>
> I'm writing a plugin here and want to figure out how to get hold of the
> dependencies as defined in the POM for my plugin.
> I'm currently using the ArtifactCollector, but it resolves transitive
> dependencies as well... I only want to have the dependencies that are
> DIRECTLY defined inside the POM-file.
>
> Any hints on how to do this?
>
> --
> Roland Asmann
>
> CFC Informationssysteme Entwicklungsgesellschaft m.b.H
> Bäckerstrasse 1/2/7
> A-1010 Wien
> FN 266155f, Handelsgericht Wien
>
> Tel.: +43/1/513 88 77 - 27
> Fax.: +43/1/513 88 62
> Email: Roland.Asmann@cfc.at
> Web: www.cfc.at
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>