You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kamlesh Sangani <xk...@yahoo.com> on 2009/01/18 00:02:26 UTC

project artifacts returns empty collection

I have a mojo which is bound to generated-sources phase. In the mojo I am calling some third party code which expects project's dependecies in the classpath. These dependencies are decalred in the project which is calling my mojo. So before calling the third party code I need to add these dependecies to the classpath. Is there a standard solution to this problem?

I have looked at the mailing list and there are some suggestions of using ${project.artifacts} to get project dependecies and then change context classloader. I tried to decalre the following configuration but artifacts is always empty set.

   /**
     * The set of artifact artifacts
     *
     * @parameter expression = "${project.artifacts}"
     * @readonly
     * @requiresDependencyResolution runtime
     */
    private Collection artifacts;

Do I need to have some other configuration in project/plugin pom to make this work? Any help is appreciated.



      

Re: AW: project artifacts returns empty collection

Posted by ksangani <xk...@yahoo.com>.
@requiresDependencyResolution fixed the problem. I needed to put the
annotation at class level and I was putting at field level. Thanks.


struberg wrote:
> 
> @requiresDependencyResolution compile
> is also a good bet in combination with project.getArtifacts() ...
> 
> hth
> 
> --- Mark Struberg <st...@yahoo.de> schrieb am So, 18.1.2009:
> 
>> Von: Mark Struberg <st...@yahoo.de>
>> Betreff: Re: AW: project artifacts returns empty collection
>> An: "Maven Users List" <us...@maven.apache.org>
>> Datum: Sonntag, 18. Januar 2009, 1:27
>> oops, sorry it's really late.
>> you may look at MavenProject
>>     /**
>>      * POM
>>      *
>>      * @parameter expression="${project}"
>>      * @readonly
>>      * @required
>>      */
>>     protected MavenProject project;
>> 
>> lg,
>> strub
>> 
>> --- Mark Struberg <st...@yahoo.de> schrieb am So,
>> 18.1.2009:
>> 
>> > Von: Mark Struberg <st...@yahoo.de>
>> > Betreff: Re: AW: project artifacts returns empty
>> collection
>> > An: "Maven Users List"
>> <us...@maven.apache.org>
>> > Datum: Sonntag, 18. Januar 2009, 1:04
>> > What does your pom look like? 
>> > Which scope do the dependencies have?
>> > In which lifecycle is your mojo being executed?
>> standard?
>> > 
>> > LieGrue,
>> > strub
>> > 
>> > 
>> > --- Kamlesh Sangani <xk...@yahoo.com>
>> schrieb am
>> > So, 18.1.2009:
>> > 
>> > > Von: Kamlesh Sangani <xk...@yahoo.com>
>> > > Betreff: Re: AW: project artifacts returns empty
>> > collection
>> > > An: "Maven Users List"
>> > <us...@maven.apache.org>
>> > > Datum: Sonntag, 18. Januar 2009, 0:45
>> > > I tried the sample code. But now for the
>> collection
>> > injected
>> > > for the expression
>> ${project.compileClasspathElements}
>> > only
>> > > has classes folder for the project. It does not
>> > include any
>> > > other dependency module jars. Any idea?
>> > > 
>> > > Other thing is third party jar that I am calling
>> uses
>> > > getClass().getClassLoader().getResource(). In
>> such
>> > case
>> > > changing thread context classloader does not
>> help. Any
>> > work
>> > > around for this use case?
>> > > 
>> > > 
>> > > 
>> > > 
>> > > ________________________________
>> > > From: Mark Struberg <st...@yahoo.de>
>> > > To: Maven Users List
>> <us...@maven.apache.org>
>> > > Sent: Saturday, January 17, 2009 3:10:38 PM
>> > > Subject: AW: project artifacts returns empty
>> > collection
>> > > 
>> > > you may look at the openjpa-maven-plugin:
>> > > 
>> > >
>> >
>> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/
>> > > 
>> > > latest version is in my git at
>> > http://ns1.backwork.net/git
>> > > 
>> > > the interesting code is in
>> > >
>> >
>> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/src/main/java/org/codehaus/mojo/openjpa/AbstractOpenJpaMojo.java
>> > > 
>> > > protected void extendRealmClasspath()
>> > > 
>> > > hth
>> > > LieGrue,
>> > > strub
>> > > 
>> > > --- Kamlesh Sangani <xk...@yahoo.com>
>> > schrieb am
>> > > So, 18.1.2009:
>> > > 
>> > > > Von: Kamlesh Sangani
>> <xk...@yahoo.com>
>> > > > Betreff: project artifacts returns empty
>> > collection
>> > > > An: users@maven.apache.org
>> > > > Datum: Sonntag, 18. Januar 2009, 0:02
>> > > > I have a mojo which is bound to
>> generated-sources
>> > > phase. In
>> > > > the mojo I am calling some third party code
>> which
>> > > expects
>> > > > project's dependecies in the classpath.
>> These
>> > > > dependencies are decalred in the project
>> which is
>> > > calling my
>> > > > mojo. So before calling the third party code
>> I
>> > need to
>> > > add
>> > > > these dependecies to the classpath. Is there
>> a
>> > > standard
>> > > > solution to this problem?
>> > > > 
>> > > > I have looked at the mailing list and there
>> are
>> > some
>> > > > suggestions of using ${project.artifacts} to
>> get
>> > > project
>> > > > dependecies and then change context
>> classloader.
>> > I
>> > > tried to
>> > > > decalre the following configuration but
>> artifacts
>> > is
>> > > always
>> > > > empty set.
>> > > > 
>> > > >    /**
>> > > >      * The set of artifact artifacts
>> > > >      *
>> > > >      * @parameter expression =
>> > > > "${project.artifacts}"
>> > > >      * @readonly
>> > > >      * @requiresDependencyResolution runtime
>> > > >      */
>> > > >     private Collection artifacts;
>> > > > 
>> > > > Do I need to have some other configuration
>> in
>> > > > project/plugin pom to make this work? Any
>> help is
>> > > > appreciated.
>> > > 
>> > > 
>> > > 
>> > > 
>> > >
>> >
>> ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail:
>> > users-unsubscribe@maven.apache.org
>> > > For additional commands, e-mail:
>> > > users-help@maven.apache.org
>> > 
>> > 
>> > 
>> > 
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail:
>> users-unsubscribe@maven.apache.org
>> > For additional commands, e-mail:
>> > users-help@maven.apache.org
>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail:
>> users-help@maven.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/project-artifacts-returns-empty-collection-tp21521970p21525875.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: AW: project artifacts returns empty collection

Posted by Kamlesh Sangani <xk...@yahoo.com>.
Thanks Mark.

1.
The project invoking mojo has a plugin declaration in <build> tag as follows.

           <plugin>
                <groupId>com.test.maven.plugins</groupId>
                <artifactId>my-maven-plugin</artifactId>
                <version>1.0-SNAPSHOT</version>
                <executions>
                    <execution>
                        <id>run</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

2.
The project also has more dependencies in default scope (compile). I can iterate through these dependencies using project.getDependencies() method. But ${project.compileClasspathElements} only has target/classes folder in it.


3. 
Mojo is executed in the standard lifecycle in generated-sources phase. i do not have any custom configuration for lifecycle.




________________________________
From: Mark Struberg <st...@yahoo.de>
To: Maven Users List <us...@maven.apache.org>
Sent: Saturday, January 17, 2009 4:04:23 PM
Subject: Re: AW: project artifacts returns empty collection

What does your pom look like? 
Which scope do the dependencies have?
In which lifecycle is your mojo being executed? standard?

LieGrue,
strub


--- Kamlesh Sangani <xk...@yahoo.com> schrieb am So, 18.1.2009:

> Von: Kamlesh Sangani <xk...@yahoo.com>
> Betreff: Re: AW: project artifacts returns empty collection
> An: "Maven Users List" <us...@maven.apache.org>
> Datum: Sonntag, 18. Januar 2009, 0:45
> I tried the sample code. But now for the collection injected
> for the expression ${project.compileClasspathElements} only
> has classes folder for the project. It does not include any
> other dependency module jars. Any idea?
> 
> Other thing is third party jar that I am calling uses
> getClass().getClassLoader().getResource(). In such case
> changing thread context classloader does not help. Any work
> around for this use case?
> 
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: Maven Users List <us...@maven.apache.org>
> Sent: Saturday, January 17, 2009 3:10:38 PM
> Subject: AW: project artifacts returns empty collection
> 
> you may look at the openjpa-maven-plugin:
> 
> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/
> 
> latest version is in my git at http://ns1.backwork.net/git
> 
> the interesting code is in
> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/src/main/java/org/codehaus/mojo/openjpa/AbstractOpenJpaMojo.java
> 
> protected void extendRealmClasspath()
> 
> hth
> LieGrue,
> strub
> 
> --- Kamlesh Sangani <xk...@yahoo.com> schrieb am
> So, 18.1.2009:
> 
> > Von: Kamlesh Sangani <xk...@yahoo.com>
> > Betreff: project artifacts returns empty collection
> > An: users@maven.apache.org
> > Datum: Sonntag, 18. Januar 2009, 0:02
> > I have a mojo which is bound to generated-sources
> phase. In
> > the mojo I am calling some third party code which
> expects
> > project's dependecies in the classpath. These
> > dependencies are decalred in the project which is
> calling my
> > mojo. So before calling the third party code I need to
> add
> > these dependecies to the classpath. Is there a
> standard
> > solution to this problem?
> > 
> > I have looked at the mailing list and there are some
> > suggestions of using ${project.artifacts} to get
> project
> > dependecies and then change context classloader. I
> tried to
> > decalre the following configuration but artifacts is
> always
> > empty set.
> > 
> >    /**
> >      * The set of artifact artifacts
> >      *
> >      * @parameter expression =
> > "${project.artifacts}"
> >      * @readonly
> >      * @requiresDependencyResolution runtime
> >      */
> >     private Collection artifacts;
> > 
> > Do I need to have some other configuration in
> > project/plugin pom to make this work? Any help is
> > appreciated.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail:
> users-help@maven.apache.org




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


      

Re: AW: project artifacts returns empty collection

Posted by Mark Struberg <st...@yahoo.de>.
@requiresDependencyResolution compile
is also a good bet in combination with project.getArtifacts() ...

hth

--- Mark Struberg <st...@yahoo.de> schrieb am So, 18.1.2009:

> Von: Mark Struberg <st...@yahoo.de>
> Betreff: Re: AW: project artifacts returns empty collection
> An: "Maven Users List" <us...@maven.apache.org>
> Datum: Sonntag, 18. Januar 2009, 1:27
> oops, sorry it's really late.
> you may look at MavenProject
>     /**
>      * POM
>      *
>      * @parameter expression="${project}"
>      * @readonly
>      * @required
>      */
>     protected MavenProject project;
> 
> lg,
> strub
> 
> --- Mark Struberg <st...@yahoo.de> schrieb am So,
> 18.1.2009:
> 
> > Von: Mark Struberg <st...@yahoo.de>
> > Betreff: Re: AW: project artifacts returns empty
> collection
> > An: "Maven Users List"
> <us...@maven.apache.org>
> > Datum: Sonntag, 18. Januar 2009, 1:04
> > What does your pom look like? 
> > Which scope do the dependencies have?
> > In which lifecycle is your mojo being executed?
> standard?
> > 
> > LieGrue,
> > strub
> > 
> > 
> > --- Kamlesh Sangani <xk...@yahoo.com>
> schrieb am
> > So, 18.1.2009:
> > 
> > > Von: Kamlesh Sangani <xk...@yahoo.com>
> > > Betreff: Re: AW: project artifacts returns empty
> > collection
> > > An: "Maven Users List"
> > <us...@maven.apache.org>
> > > Datum: Sonntag, 18. Januar 2009, 0:45
> > > I tried the sample code. But now for the
> collection
> > injected
> > > for the expression
> ${project.compileClasspathElements}
> > only
> > > has classes folder for the project. It does not
> > include any
> > > other dependency module jars. Any idea?
> > > 
> > > Other thing is third party jar that I am calling
> uses
> > > getClass().getClassLoader().getResource(). In
> such
> > case
> > > changing thread context classloader does not
> help. Any
> > work
> > > around for this use case?
> > > 
> > > 
> > > 
> > > 
> > > ________________________________
> > > From: Mark Struberg <st...@yahoo.de>
> > > To: Maven Users List
> <us...@maven.apache.org>
> > > Sent: Saturday, January 17, 2009 3:10:38 PM
> > > Subject: AW: project artifacts returns empty
> > collection
> > > 
> > > you may look at the openjpa-maven-plugin:
> > > 
> > >
> >
> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/
> > > 
> > > latest version is in my git at
> > http://ns1.backwork.net/git
> > > 
> > > the interesting code is in
> > >
> >
> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/src/main/java/org/codehaus/mojo/openjpa/AbstractOpenJpaMojo.java
> > > 
> > > protected void extendRealmClasspath()
> > > 
> > > hth
> > > LieGrue,
> > > strub
> > > 
> > > --- Kamlesh Sangani <xk...@yahoo.com>
> > schrieb am
> > > So, 18.1.2009:
> > > 
> > > > Von: Kamlesh Sangani
> <xk...@yahoo.com>
> > > > Betreff: project artifacts returns empty
> > collection
> > > > An: users@maven.apache.org
> > > > Datum: Sonntag, 18. Januar 2009, 0:02
> > > > I have a mojo which is bound to
> generated-sources
> > > phase. In
> > > > the mojo I am calling some third party code
> which
> > > expects
> > > > project's dependecies in the classpath.
> These
> > > > dependencies are decalred in the project
> which is
> > > calling my
> > > > mojo. So before calling the third party code
> I
> > need to
> > > add
> > > > these dependecies to the classpath. Is there
> a
> > > standard
> > > > solution to this problem?
> > > > 
> > > > I have looked at the mailing list and there
> are
> > some
> > > > suggestions of using ${project.artifacts} to
> get
> > > project
> > > > dependecies and then change context
> classloader.
> > I
> > > tried to
> > > > decalre the following configuration but
> artifacts
> > is
> > > always
> > > > empty set.
> > > > 
> > > >    /**
> > > >      * The set of artifact artifacts
> > > >      *
> > > >      * @parameter expression =
> > > > "${project.artifacts}"
> > > >      * @readonly
> > > >      * @requiresDependencyResolution runtime
> > > >      */
> > > >     private Collection artifacts;
> > > > 
> > > > Do I need to have some other configuration
> in
> > > > project/plugin pom to make this work? Any
> help is
> > > > appreciated.
> > > 
> > > 
> > > 
> > > 
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail:
> > > users-help@maven.apache.org
> > 
> > 
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> users-unsubscribe@maven.apache.org
> > For additional commands, e-mail:
> > users-help@maven.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail:
> users-help@maven.apache.org


      

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


Re: AW: project artifacts returns empty collection

Posted by Mark Struberg <st...@yahoo.de>.
oops, sorry it's really late.
you may look at MavenProject
    /**
     * POM
     *
     * @parameter expression="${project}"
     * @readonly
     * @required
     */
    protected MavenProject project;

lg,
strub

--- Mark Struberg <st...@yahoo.de> schrieb am So, 18.1.2009:

> Von: Mark Struberg <st...@yahoo.de>
> Betreff: Re: AW: project artifacts returns empty collection
> An: "Maven Users List" <us...@maven.apache.org>
> Datum: Sonntag, 18. Januar 2009, 1:04
> What does your pom look like? 
> Which scope do the dependencies have?
> In which lifecycle is your mojo being executed? standard?
> 
> LieGrue,
> strub
> 
> 
> --- Kamlesh Sangani <xk...@yahoo.com> schrieb am
> So, 18.1.2009:
> 
> > Von: Kamlesh Sangani <xk...@yahoo.com>
> > Betreff: Re: AW: project artifacts returns empty
> collection
> > An: "Maven Users List"
> <us...@maven.apache.org>
> > Datum: Sonntag, 18. Januar 2009, 0:45
> > I tried the sample code. But now for the collection
> injected
> > for the expression ${project.compileClasspathElements}
> only
> > has classes folder for the project. It does not
> include any
> > other dependency module jars. Any idea?
> > 
> > Other thing is third party jar that I am calling uses
> > getClass().getClassLoader().getResource(). In such
> case
> > changing thread context classloader does not help. Any
> work
> > around for this use case?
> > 
> > 
> > 
> > 
> > ________________________________
> > From: Mark Struberg <st...@yahoo.de>
> > To: Maven Users List <us...@maven.apache.org>
> > Sent: Saturday, January 17, 2009 3:10:38 PM
> > Subject: AW: project artifacts returns empty
> collection
> > 
> > you may look at the openjpa-maven-plugin:
> > 
> >
> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/
> > 
> > latest version is in my git at
> http://ns1.backwork.net/git
> > 
> > the interesting code is in
> >
> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/src/main/java/org/codehaus/mojo/openjpa/AbstractOpenJpaMojo.java
> > 
> > protected void extendRealmClasspath()
> > 
> > hth
> > LieGrue,
> > strub
> > 
> > --- Kamlesh Sangani <xk...@yahoo.com>
> schrieb am
> > So, 18.1.2009:
> > 
> > > Von: Kamlesh Sangani <xk...@yahoo.com>
> > > Betreff: project artifacts returns empty
> collection
> > > An: users@maven.apache.org
> > > Datum: Sonntag, 18. Januar 2009, 0:02
> > > I have a mojo which is bound to generated-sources
> > phase. In
> > > the mojo I am calling some third party code which
> > expects
> > > project's dependecies in the classpath. These
> > > dependencies are decalred in the project which is
> > calling my
> > > mojo. So before calling the third party code I
> need to
> > add
> > > these dependecies to the classpath. Is there a
> > standard
> > > solution to this problem?
> > > 
> > > I have looked at the mailing list and there are
> some
> > > suggestions of using ${project.artifacts} to get
> > project
> > > dependecies and then change context classloader.
> I
> > tried to
> > > decalre the following configuration but artifacts
> is
> > always
> > > empty set.
> > > 
> > >    /**
> > >      * The set of artifact artifacts
> > >      *
> > >      * @parameter expression =
> > > "${project.artifacts}"
> > >      * @readonly
> > >      * @requiresDependencyResolution runtime
> > >      */
> > >     private Collection artifacts;
> > > 
> > > Do I need to have some other configuration in
> > > project/plugin pom to make this work? Any help is
> > > appreciated.
> > 
> > 
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> users-unsubscribe@maven.apache.org
> > For additional commands, e-mail:
> > users-help@maven.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail:
> users-help@maven.apache.org


      

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


Re: AW: project artifacts returns empty collection

Posted by Mark Struberg <st...@yahoo.de>.
What does your pom look like? 
Which scope do the dependencies have?
In which lifecycle is your mojo being executed? standard?

LieGrue,
strub


--- Kamlesh Sangani <xk...@yahoo.com> schrieb am So, 18.1.2009:

> Von: Kamlesh Sangani <xk...@yahoo.com>
> Betreff: Re: AW: project artifacts returns empty collection
> An: "Maven Users List" <us...@maven.apache.org>
> Datum: Sonntag, 18. Januar 2009, 0:45
> I tried the sample code. But now for the collection injected
> for the expression ${project.compileClasspathElements} only
> has classes folder for the project. It does not include any
> other dependency module jars. Any idea?
> 
> Other thing is third party jar that I am calling uses
> getClass().getClassLoader().getResource(). In such case
> changing thread context classloader does not help. Any work
> around for this use case?
> 
> 
> 
> 
> ________________________________
> From: Mark Struberg <st...@yahoo.de>
> To: Maven Users List <us...@maven.apache.org>
> Sent: Saturday, January 17, 2009 3:10:38 PM
> Subject: AW: project artifacts returns empty collection
> 
> you may look at the openjpa-maven-plugin:
> 
> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/
> 
> latest version is in my git at http://ns1.backwork.net/git
> 
> the interesting code is in
> https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/src/main/java/org/codehaus/mojo/openjpa/AbstractOpenJpaMojo.java
> 
> protected void extendRealmClasspath()
> 
> hth
> LieGrue,
> strub
> 
> --- Kamlesh Sangani <xk...@yahoo.com> schrieb am
> So, 18.1.2009:
> 
> > Von: Kamlesh Sangani <xk...@yahoo.com>
> > Betreff: project artifacts returns empty collection
> > An: users@maven.apache.org
> > Datum: Sonntag, 18. Januar 2009, 0:02
> > I have a mojo which is bound to generated-sources
> phase. In
> > the mojo I am calling some third party code which
> expects
> > project's dependecies in the classpath. These
> > dependencies are decalred in the project which is
> calling my
> > mojo. So before calling the third party code I need to
> add
> > these dependecies to the classpath. Is there a
> standard
> > solution to this problem?
> > 
> > I have looked at the mailing list and there are some
> > suggestions of using ${project.artifacts} to get
> project
> > dependecies and then change context classloader. I
> tried to
> > decalre the following configuration but artifacts is
> always
> > empty set.
> > 
> >    /**
> >      * The set of artifact artifacts
> >      *
> >      * @parameter expression =
> > "${project.artifacts}"
> >      * @readonly
> >      * @requiresDependencyResolution runtime
> >      */
> >     private Collection artifacts;
> > 
> > Do I need to have some other configuration in
> > project/plugin pom to make this work? Any help is
> > appreciated.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail:
> users-help@maven.apache.org


      

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


Re: AW: project artifacts returns empty collection

Posted by Kamlesh Sangani <xk...@yahoo.com>.
I tried the sample code. But now for the collection injected for the expression ${project.compileClasspathElements} only has classes folder for the project. It does not include any other dependency module jars. Any idea?

Other thing is third party jar that I am calling uses getClass().getClassLoader().getResource(). In such case changing thread context classloader does not help. Any work around for this use case?




________________________________
From: Mark Struberg <st...@yahoo.de>
To: Maven Users List <us...@maven.apache.org>
Sent: Saturday, January 17, 2009 3:10:38 PM
Subject: AW: project artifacts returns empty collection

you may look at the openjpa-maven-plugin:

https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/

latest version is in my git at http://ns1.backwork.net/git

the interesting code is in
https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/src/main/java/org/codehaus/mojo/openjpa/AbstractOpenJpaMojo.java

protected void extendRealmClasspath()

hth
LieGrue,
strub

--- Kamlesh Sangani <xk...@yahoo.com> schrieb am So, 18.1.2009:

> Von: Kamlesh Sangani <xk...@yahoo.com>
> Betreff: project artifacts returns empty collection
> An: users@maven.apache.org
> Datum: Sonntag, 18. Januar 2009, 0:02
> I have a mojo which is bound to generated-sources phase. In
> the mojo I am calling some third party code which expects
> project's dependecies in the classpath. These
> dependencies are decalred in the project which is calling my
> mojo. So before calling the third party code I need to add
> these dependecies to the classpath. Is there a standard
> solution to this problem?
> 
> I have looked at the mailing list and there are some
> suggestions of using ${project.artifacts} to get project
> dependecies and then change context classloader. I tried to
> decalre the following configuration but artifacts is always
> empty set.
> 
>    /**
>      * The set of artifact artifacts
>      *
>      * @parameter expression =
> "${project.artifacts}"
>      * @readonly
>      * @requiresDependencyResolution runtime
>      */
>     private Collection artifacts;
> 
> Do I need to have some other configuration in
> project/plugin pom to make this work? Any help is
> appreciated.




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


      

AW: project artifacts returns empty collection

Posted by Mark Struberg <st...@yahoo.de>.
you may look at the openjpa-maven-plugin:

https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/

latest version is in my git at http://ns1.backwork.net/git

the interesting code is in
https://svn.codehaus.org/mojo/trunk/mojo/openjpa-maven-plugin/src/main/java/org/codehaus/mojo/openjpa/AbstractOpenJpaMojo.java

protected void extendRealmClasspath()

hth
LieGrue,
strub

--- Kamlesh Sangani <xk...@yahoo.com> schrieb am So, 18.1.2009:

> Von: Kamlesh Sangani <xk...@yahoo.com>
> Betreff: project artifacts returns empty collection
> An: users@maven.apache.org
> Datum: Sonntag, 18. Januar 2009, 0:02
> I have a mojo which is bound to generated-sources phase. In
> the mojo I am calling some third party code which expects
> project's dependecies in the classpath. These
> dependencies are decalred in the project which is calling my
> mojo. So before calling the third party code I need to add
> these dependecies to the classpath. Is there a standard
> solution to this problem?
> 
> I have looked at the mailing list and there are some
> suggestions of using ${project.artifacts} to get project
> dependecies and then change context classloader. I tried to
> decalre the following configuration but artifacts is always
> empty set.
> 
>    /**
>      * The set of artifact artifacts
>      *
>      * @parameter expression =
> "${project.artifacts}"
>      * @readonly
>      * @requiresDependencyResolution runtime
>      */
>     private Collection artifacts;
> 
> Do I need to have some other configuration in
> project/plugin pom to make this work? Any help is
> appreciated.


      

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