You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by James Crawford <ja...@distra.com> on 2009/05/07 09:11:49 UTC

Access to the class path

Hi,

I need to be able to get access to the runtime class path
in my tests when invoked from the maven-surefire-plugin.

I can set system properties for the surefire plugin but I
can't find anyway that I can get access to the class path.

For example I want to do something like the following to
set some "runtime.classpath" system property (assuming maven
provided a "maven.runtime.classpath" property):

  <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <forkMode>always</forkMode>
      <systemProperties>
        <property>
          <name>runtime.classpath</name>
          <value>${maven.runtime.classpath}</value>
        </property>
      </systemProperties>
    </configuration>
    <executions>
      ...
    </executions>
  </plugin>

I can see that when running ant tasks the antrun plugin
provides access to this type of information but I can't
find anywhere where it is possible to get access to this
information in a general way within Maven without writing
my own plugin.

Can anyone tell me whether it is possible to do what I
want?

Thanks,
James.



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


Re: Access to the class path

Posted by Brian Fox <br...@infinity.nu>.
No, that would be a bug.

On Thu, May 7, 2009 at 9:01 PM, James Crawford <ja...@distra.com>wrote:

> On Thu, 2009-05-07 at 20:34 -0400, Brian Fox wrote:
> > Yeah, someone else was looking for this too. If you supply a patch, i'll
> > integrate it.
>
> We are currently on Maven 2.0.4 so I can't even build the latest
> source.
>
> If I get time I will produce a patch when we finally upgrade to
> a more recent version of aven.
>
> > On Thu, May 7, 2009 at 8:28 PM, Manos Batsis <manos_lists@geekologue.com
> >wrote:
> >
> > > James Crawford wrote:
> > >
> > >> I did look at dependency:build-classpath but I could only
> > >> see how it outputs the class path to a file.
>
> One thing I noticed is that the classpath seems to be sorted
> alphabetically when using the dependency:build-classpath goal
> and thus differs from the project.getClasspathElements() call
> which is what I would have expected the results to look like.
>
> Is there a reason for this?
>
> Cheers,
> James.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Access to the class path

Posted by James Crawford <ja...@distra.com>.
On Thu, 2009-05-07 at 20:34 -0400, Brian Fox wrote:
> Yeah, someone else was looking for this too. If you supply a patch, i'll
> integrate it.

We are currently on Maven 2.0.4 so I can't even build the latest
source.

If I get time I will produce a patch when we finally upgrade to
a more recent version of aven.

> On Thu, May 7, 2009 at 8:28 PM, Manos Batsis <ma...@geekologue.com>wrote:
> 
> > James Crawford wrote:
> >
> >> I did look at dependency:build-classpath but I could only
> >> see how it outputs the class path to a file.

One thing I noticed is that the classpath seems to be sorted 
alphabetically when using the dependency:build-classpath goal
and thus differs from the project.getClasspathElements() call
which is what I would have expected the results to look like.

Is there a reason for this?

Cheers,
James.



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


Re: Access to the class path

Posted by Brian Fox <br...@infinity.nu>.
Yeah, someone else was looking for this too. If you supply a patch, i'll
integrate it.

On Thu, May 7, 2009 at 8:28 PM, Manos Batsis <ma...@geekologue.com>wrote:

> James Crawford wrote:
>
>> I did look at dependency:build-classpath but I could only
>> see how it outputs the class path to a file.
>>
>>
>
> Probably not the best idea as I've been up straight waaaay too long, but it
> should take you 15 minutes to change the source so that an env property is
> stored.
>
> Manos
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Access to the class path

Posted by Manos Batsis <ma...@geekologue.com>.
James Crawford wrote:
> I did look at dependency:build-classpath but I could only
> see how it outputs the class path to a file.
> 


Probably not the best idea as I've been up straight waaaay too long, but 
it should take you 15 minutes to change the source so that an env 
property is stored.

Manos

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


Re: Access to the class path

Posted by James Crawford <ja...@distra.com>.
I did look at dependency:build-classpath but I could only
see how it outputs the class path to a file.

>>From the web page:

"This goal will output a classpath string of dependencies
 from the local repository to a file or log."

Is there anyway to get access to it as a property?

I guess I could always write it out to a file and then read
it from the file in my tests but it seems a convoluted...

Cheers,
James.

On Thu, 2009-05-07 at 18:08 -0400, Brian Fox wrote:
> take a look at dependency:build-classpath
> 
> On Thu, May 7, 2009 at 3:11 AM, James Crawford <ja...@distra.com>wrote:
> 
> > Hi,
> >
> > I need to be able to get access to the runtime class path
> > in my tests when invoked from the maven-surefire-plugin.
> >
> > I can set system properties for the surefire plugin but I
> > can't find anyway that I can get access to the class path.
> >
> > For example I want to do something like the following to
> > set some "runtime.classpath" system property (assuming maven
> > provided a "maven.runtime.classpath" property):
> >
> >  <plugin>
> >    <artifactId>maven-surefire-plugin</artifactId>
> >    <configuration>
> >      <forkMode>always</forkMode>
> >      <systemProperties>
> >        <property>
> >          <name>runtime.classpath</name>
> >          <value>${maven.runtime.classpath}</value>
> >        </property>
> >      </systemProperties>
> >    </configuration>
> >    <executions>
> >      ...
> >    </executions>
> >  </plugin>
> >
> > I can see that when running ant tasks the antrun plugin
> > provides access to this type of information but I can't
> > find anywhere where it is possible to get access to this
> > information in a general way within Maven without writing
> > my own plugin.
> >
> > Can anyone tell me whether it is possible to do what I
> > want?
> >
> > Thanks,
> > James.
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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: Access to the class path

Posted by Brian Fox <br...@infinity.nu>.
take a look at dependency:build-classpath

On Thu, May 7, 2009 at 3:11 AM, James Crawford <ja...@distra.com>wrote:

> Hi,
>
> I need to be able to get access to the runtime class path
> in my tests when invoked from the maven-surefire-plugin.
>
> I can set system properties for the surefire plugin but I
> can't find anyway that I can get access to the class path.
>
> For example I want to do something like the following to
> set some "runtime.classpath" system property (assuming maven
> provided a "maven.runtime.classpath" property):
>
>  <plugin>
>    <artifactId>maven-surefire-plugin</artifactId>
>    <configuration>
>      <forkMode>always</forkMode>
>      <systemProperties>
>        <property>
>          <name>runtime.classpath</name>
>          <value>${maven.runtime.classpath}</value>
>        </property>
>      </systemProperties>
>    </configuration>
>    <executions>
>      ...
>    </executions>
>  </plugin>
>
> I can see that when running ant tasks the antrun plugin
> provides access to this type of information but I can't
> find anywhere where it is possible to get access to this
> information in a general way within Maven without writing
> my own plugin.
>
> Can anyone tell me whether it is possible to do what I
> want?
>
> Thanks,
> James.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>