You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Jeremy Lewi <je...@lewi.us> on 2011/06/26 18:53:23 UTC

Classpath for java

Hi,

I'm having trouble understanding how the class path is being set by
maven for java. 

When I run a unit test using the maven surefire plugin
cd lang/java
mvn -Dtest=org.apache.avro.mapred.TestWordCount test -X

The output shows the following directories are on the classpath.
lang/java/mapred/target/test-classes
lang/java/mapred/target/classes
lang/java/ipc/target/classes
lang/java/avro/target/classes

But when I try to execute a class (I put a main method in
lang/java/.../Pair.java for testing)
 mvn exec:exec -Dexec.mainClass=Pair -X

Only 
lang/java/target/classes 
is on the path.

So I'm trying to determine how to configure the exec plugin to properly
set the class path so that I can execute programs.

If anyone has any pointers I would greatly appreciate it.

Thanks

J



Re: Classpath for java

Posted by Jeremy Lewi <je...@lewi.us>.
Thanks for the tip Scott.

It looks like there may have been a couple issues
1) I needed to do an mvn install at the top level to install all the
other modules
2) I Pair is a generic class so I think that could be an issue with
making executable.
3) Running from java/mapred as opposed to the top-level appeared to
work.

Thanks
J

On Sun, 2011-06-26 at 12:08 -0700, Scott Carey wrote:
> I suspect that you will need to go into the module with the Pair class.
> When executing a maven plugin directly from the command line (exec:exec)
> the maven 'scope' is very restricted, and when you do this on the top
> level project it executes on that project only by default.
> 
> The surefire test plugin occurs in the test phase, after it has finished
> all of the prior phases including compiling and constructing all the paths
> required for testing.
> 
> On 6/26/11 9:53 AM, "Jeremy Lewi" <je...@lewi.us> wrote:
> 
> >Hi,
> >
> >I'm having trouble understanding how the class path is being set by
> >maven for java. 
> >
> >When I run a unit test using the maven surefire plugin
> >cd lang/java
> >mvn -Dtest=org.apache.avro.mapred.TestWordCount test -X
> >
> >The output shows the following directories are on the classpath.
> >lang/java/mapred/target/test-classes
> >lang/java/mapred/target/classes
> >lang/java/ipc/target/classes
> >lang/java/avro/target/classes
> >
> >But when I try to execute a class (I put a main method in
> >lang/java/.../Pair.java for testing)
> > mvn exec:exec -Dexec.mainClass=Pair -X
> >
> >Only 
> >lang/java/target/classes
> >is on the path.
> >
> >So I'm trying to determine how to configure the exec plugin to properly
> >set the class path so that I can execute programs.
> >
> >If anyone has any pointers I would greatly appreciate it.
> >
> >Thanks
> >
> >J
> >
> >
> 


Re: Classpath for java

Posted by Scott Carey <sc...@richrelevance.com>.
I suspect that you will need to go into the module with the Pair class.
When executing a maven plugin directly from the command line (exec:exec)
the maven 'scope' is very restricted, and when you do this on the top
level project it executes on that project only by default.

The surefire test plugin occurs in the test phase, after it has finished
all of the prior phases including compiling and constructing all the paths
required for testing.

On 6/26/11 9:53 AM, "Jeremy Lewi" <je...@lewi.us> wrote:

>Hi,
>
>I'm having trouble understanding how the class path is being set by
>maven for java. 
>
>When I run a unit test using the maven surefire plugin
>cd lang/java
>mvn -Dtest=org.apache.avro.mapred.TestWordCount test -X
>
>The output shows the following directories are on the classpath.
>lang/java/mapred/target/test-classes
>lang/java/mapred/target/classes
>lang/java/ipc/target/classes
>lang/java/avro/target/classes
>
>But when I try to execute a class (I put a main method in
>lang/java/.../Pair.java for testing)
> mvn exec:exec -Dexec.mainClass=Pair -X
>
>Only 
>lang/java/target/classes
>is on the path.
>
>So I'm trying to determine how to configure the exec plugin to properly
>set the class path so that I can execute programs.
>
>If anyone has any pointers I would greatly appreciate it.
>
>Thanks
>
>J
>
>