On 2/10/06, Dion Gillard <[EMAIL PROTECTED]> wrote:
> On 2/10/06, Davis Ford <[EMAIL PROTECTED]> wrote:
> > No, they run in the same JVM.
> >
> > This is a pretty simple test that anyone can do.  Write a quick main
> > program that does the following:
> >
> > System.out.println(System.getProperty("java.class.path"));
> >
> > You'll get something like this:
> >
> > ..\Apache Software Foundation\Maven 1.0.2\lib\forehead-1.0-beta-5.jar
>
> Yep, that's exactly what we would expect. When you run maven.bat/sh it
> launches a JVM with a specific classpath, as you've got it above.
>
>
> >
> > It seems to me, unless something is specifcally wrong with my
> > environment, that you can't write code that navigates through the
> > classpath if you want to build with maven.  This seems like a big
> > limitation.  Am I the only one that has this problem?
>
> The problem here is that you're after "the classpath" as if you mean
> the environment variable, $CLASSPATH or %CLASSPATH%.  The batch
> file/shell script that launches maven creates it's own classpath. If
> you need the variable as it exists BEFORE maven runs, you'll need to
> get it some other way.
>
> Mostly tests don't navigate through the class path. What is it that
> you need from it?

Hi Dion, any suggestion on how to get it before maven erases it?  My
unit test doesn't need the classpath, but the code it is testing does
expect to be able to navigate into the '.' current directory that is
part of the classpath, and look at the class files that are in the
package hierarchy.  When my unit test runs on this code, it fails. 
For example, this is part of the code that is being tested:

private static final String CLASS_PATH = System.getProperty("java.class.path");
private static final String PATH_SEPARATOR =
System.getProperty("path.separator");
...
StringTokenizer tokens = new StringTokenizer(CLASS_PATH, PATH_SEPARATOR);
while (tokens.hasMoreTokens()) {
...

The while loop quits right away, b/c the claspath only contains one
item, whereas within eclipse the classpath is like:

C:\some\dir; C:\some\other\dir ; C:\yet\another\dir ; etc..

I want to navigate into the package hierarchy that is

...\target\classes\my\package\hierarchy

This works in eclipse with the approach above, but it fails with
maven.  I'm not saying this is the only/best way to do this.  If you
have another suggestion, please let me know.

Regards,
Davis

PS: Is there a plugin.properties somewhere that I can override so this
will work with Maven?

> >
> > --davis
> > On 2/9/06, Dion Gillard <[EMAIL PROTECTED]> wrote:
> > > So, are the tests being forked?
> > >
> > > On 2/10/06, Davis Ford <[EMAIL PROTECTED]> wrote:
> > > > Hello Dion,
> > > >
> > > > Thanks for responding.  I should clarify -- the unit tests I am
> > > > running are testing some code that use
> > > > System.getProperty("java.class.path") -- and this code depends on the
> > > > fact that the call to System.getProperty("java.class.path") will
> > > > include "." which is the current directory - wherever that may be.
> > > > So, when maven overrides that system property, my tests fail.
> > > >
> > > > Regards,
> > > > Davis
> > > >
> > > > On 2/9/06, Dion Gillard <[EMAIL PROTECTED]> wrote:
> > > > > Why does your test need the classpath of the app that is running it?
> > > > >
> > > > > The java.class.path property is set by the JVM when it's launched.
> > > > >
> > > > > Are you forking your tests?
> > > > >
> > > > > On 2/10/06, Davis Ford <[EMAIL PROTECTED]> wrote:
> > > > > > Hi, I searched high and low on google, etc. and the mailing list
> > > > > > archives.  This means either my problem is unique, or I'm just doing
> > > > > > something very dumb.  I know maven is supposed to handle 
> > > > > > dependencies
> > > > > > like jar files with the xml, but this is a case where:
> > > > > >
> > > > > > A unit test is run that introspects the current classpath.  The test
> > > > > > fails b/c maven seems to override the classpath...at least through
> > > > > > System.getProperty("java.class.path")
> > > > > >
> > > > > > I tried adding the following to project.properties
> > > > > >
> > > > > > maven.junit.jvmargs=-classpath C:\some\dir\path
> > > > > >
> > > > > > but that had no effect.  My guess is that I can maybe fix this via
> > > > > > over-riding the right property, but the number of property key/value
> > > > > > pairs for all the plugins is a bit over-whelming.  Can someone 
> > > > > > provide
> > > > > > a hint?
> > > > > >
> > > > > > Thanks,
> > > > > > Davis
> > > > > >
> > > > > > > Hi, I wrote some code that uses the class path string from:
> > > > > > >
> > > > > > > System.getProperty("java.class.path");
> > > > > > >
> > > > > > > When I build with Maven on the command line it, this code:
> > > > > > >
> > > > > > > System.out.println(System.getProperty ("java.class.path");
> > > > > > >
> > > > > > > produces this output:
> > > > > > >
> > > > > > > C:\Program Files\Apache Software Foundation\Maven
> > > > > > > 1.0.2\lib\forehead-1.0-beta-5.jar
> > > > > > >
> > > > > > > When I run the same code from inside Eclipse, it produces the 
> > > > > > > output I
> > > > > > > expect which is a long string of file directories separated by 
> > > > > > > ';' -- this
> > > > > > > is what I need.
> > > > > > >
> > > > > > > Why doesn't it work with maven cmd line build?
> > > > > > > Why does maven seem to override that system property?
> > > > > > > Is there some easy fix?
> > > > > > >
> > > > > > > Regards,
> > > > > > > Davis
> > > > > > >
> > > > > > >
> > > > > >
> > > > > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > http://www.multitask.com.au/people/dion/
> > > > > "If I close my eyes it doesn't seem so dark." - SpongeBob SquarePants
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > 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]
> > > >
> > > >
> > >
> > >
> > > --
> > > http://www.multitask.com.au/people/dion/
> > > "If I close my eyes it doesn't seem so dark." - SpongeBob SquarePants
> > >
> > > ---------------------------------------------------------------------
> > > 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]
> >
> >
>
>
> --
> http://www.multitask.com.au/people/dion/
> "If I close my eyes it doesn't seem so dark." - SpongeBob SquarePants
>
> ---------------------------------------------------------------------
> 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