You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stefan Arentz <st...@gmail.com> on 2006/04/27 21:44:50 UTC

Some simple questions from a Maven 2.0 n00b

My test in src/test/java cannot find classes in src/main/java. How do I tell
Maven to add those to the classpath when testing?

I have a simple project with a main() in it. The jar is succesfully created
but how do I run it? Is there a Maven shortcut?

 S.

Re: Some simple questions from a Maven 2.0 n00b

Posted by Wayne Fay <wa...@gmail.com>.
Search Maven User archive for "jar-with-dependencies". I belive this
is what you want.

But I don't use it myself, so not 100% sure. Nor do I know the proper
pom.xml configuration... ;-)

Wayne

On 4/27/06, Stefan Arentz <st...@gmail.com> wrote:
> On 4/27/06, Wayne Fay <wa...@gmail.com> wrote:
> >
> > Maven is a project builder, not a project runner. There is no Maven
> > shortcut to run your main(). I have seen some people talk about
> > POMstrap so Google that and maybe you'll find something.
>
>
> Ok. Is there a way to package a jar then, that I can execute with java -jar?
>
>
> > As for your test problem, I have no idea what you're doing in your
> > configuration, this works properly out of the box. I assume you've
> > broken something in your pom.xml, or you're doing something
> > wacky/tricky in your tests.
>
>
>
> I was doing something stupid of course. And it does work out of the box.
>
> Thanks,
>
>  S.
>
>

Re: Some simple questions from a Maven 2.0 n00b

Posted by Kees de Kooter <kd...@gmail.com>.
Exactly. I also use the dependencies plugin to copy all dependent jars
to the lib dir. The finishing touch is a manual copy of this lib dir
and the built jar to the deploy dir ;-)

Kees

On 4/28/06, Wayne Fay <wa...@gmail.com> wrote:
> Note however that this won't work if you have any dependencies that
> aren't on your classpath somewhere. Your jar will run but you'll error
> out very quickly due to JVM failure to find classes. ;-)
>
> Basically, there is no completely trivial way to solve this problem
> that I'm aware of. But instead lots of little things you can do to
> help get your project running.
>
> Wayne
>

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


Re: Some simple questions from a Maven 2.0 n00b

Posted by Wayne Fay <wa...@gmail.com>.
Note however that this won't work if you have any dependencies that
aren't on your classpath somewhere. Your jar will run but you'll error
out very quickly due to JVM failure to find classes. ;-)

Basically, there is no completely trivial way to solve this problem
that I'm aware of. But instead lots of little things you can do to
help get your project running.

Wayne

On 4/27/06, Kees de Kooter <kd...@gmail.com> wrote:
> You can create an "executable" jar by adding the following plugin configuration:
>
>      <plugin>
>        <artifactId>maven-jar-plugin</artifactId>
>        <configuration>
>          <archive>
>            <manifest>
>              <mainClass>your.main.clas</mainClass>
>              <addClasspath>true</addClasspath>
>              <classpathPrefix>lib/</classpathPrefix>
>            </manifest>
>          </archive>
>        </configuration>
>      </plugin>
>
>
> On 4/27/06, Stefan Arentz <st...@gmail.com> wrote:
> > On 4/27/06, Wayne Fay <wa...@gmail.com> wrote:
> > >
> > > Maven is a project builder, not a project runner. There is no Maven
> > > shortcut to run your main(). I have seen some people talk about
> > > POMstrap so Google that and maybe you'll find something.
> >
> >
> > Ok. Is there a way to package a jar then, that I can execute with java -jar?
> >
> >
> > > As for your test problem, I have no idea what you're doing in your
> > > configuration, this works properly out of the box. I assume you've
> > > broken something in your pom.xml, or you're doing something
> > > wacky/tricky in your tests.
> >
> >
> >
> > I was doing something stupid of course. And it does work out of the box.
> >
> > Thanks,
> >
> >  S.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Some simple questions from a Maven 2.0 n00b

Posted by Kees de Kooter <kd...@gmail.com>.
You can create an "executable" jar by adding the following plugin configuration:

      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>your.main.clas</mainClass>
              <addClasspath>true</addClasspath>
              <classpathPrefix>lib/</classpathPrefix>
            </manifest>
          </archive>
        </configuration>
      </plugin>


On 4/27/06, Stefan Arentz <st...@gmail.com> wrote:
> On 4/27/06, Wayne Fay <wa...@gmail.com> wrote:
> >
> > Maven is a project builder, not a project runner. There is no Maven
> > shortcut to run your main(). I have seen some people talk about
> > POMstrap so Google that and maybe you'll find something.
>
>
> Ok. Is there a way to package a jar then, that I can execute with java -jar?
>
>
> > As for your test problem, I have no idea what you're doing in your
> > configuration, this works properly out of the box. I assume you've
> > broken something in your pom.xml, or you're doing something
> > wacky/tricky in your tests.
>
>
>
> I was doing something stupid of course. And it does work out of the box.
>
> Thanks,
>
>  S.
>

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


Re: Some simple questions from a Maven 2.0 n00b

Posted by Stefan Arentz <st...@gmail.com>.
On 4/27/06, Wayne Fay <wa...@gmail.com> wrote:
>
> Maven is a project builder, not a project runner. There is no Maven
> shortcut to run your main(). I have seen some people talk about
> POMstrap so Google that and maybe you'll find something.


Ok. Is there a way to package a jar then, that I can execute with java -jar?


> As for your test problem, I have no idea what you're doing in your
> configuration, this works properly out of the box. I assume you've
> broken something in your pom.xml, or you're doing something
> wacky/tricky in your tests.



I was doing something stupid of course. And it does work out of the box.

Thanks,

 S.

Re: Some simple questions from a Maven 2.0 n00b

Posted by Wayne Fay <wa...@gmail.com>.
Maven is a project builder, not a project runner. There is no Maven
shortcut to run your main(). I have seen some people talk about
POMstrap so Google that and maybe you'll find something.

As for your test problem, I have no idea what you're doing in your
configuration, this works properly out of the box. I assume you've
broken something in your pom.xml, or you're doing something
wacky/tricky in your tests.

Send us the relevant portions of your pom.xml and the error messages
you're seeing and we'll try to help more.

Wayne

On 4/27/06, Stefan Arentz <st...@gmail.com> wrote:
> My test in src/test/java cannot find classes in src/main/java. How do I tell
> Maven to add those to the classpath when testing?
>
> I have a simple project with a main() in it. The jar is succesfully created
> but how do I run it? Is there a Maven shortcut?
>
>  S.
>
>