You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kevin Galligan <ma...@kgalligan.com> on 2006/04/13 13:48:39 UTC
Executing a maven class application
I was wondering if there is some utility out there for this.
Build a maven jar package for a simple 1-off app. Could be something
bigger, but basically you want to execute this on the command line. What I
do now is run assembly with 'jar-with-dependencies' (if that's not exactly
it, you know what I mean). Then I manually set up my command line with...
java -cp target\whatever-1.0-SNAPSHOT-with-dependencies.jar
com.package.Apparg0 arg1 ...
The problem here is that you have to have the full path info for the
classpath, and always have to run the assembly deal. I was thinking one or
both of two things.
mvn-run groupId=com.example.example-app artifactId=example-app
com.package.App arg0 arg1
The 'mvn-run' code would add to the classpath according to the group and
package info in the repository.
It might also be possible to add groupId and artifactId as environment
variables and just run...
mvn-run com.package.App arg0 arg1
Obviously version would be an optional argument.
(I just went and checked the maven bin folder to make sure this exact thing
wasn't already there)
Ok. The other one. Closely related, but I'm not sure of the value. An
execute plugin.
mvn exe:exe -DappClass=com.package.App -Dargruments='arg0 arg1'
I've been up really late working, so this might be nonsense, but I know this
is a common useage patter that I have and it gets clunky because of the
classpath, etc. Any thoughts?
Re: Executing a maven class application
Posted by Arnaud Bailly <ab...@norsys.fr>.
Hi,
In one project, we have a launcher module that contains a special
class which is like the commons-launcher project. This class is set to
be the main-class of the launcher jar and it creates a classloader
from directories given as a property.
Then, we run
$> mvn assembly
which generates a distribution containing all dependencies in a lib/
dir, configs in conf/ ... and simple windows and unix scripts in bin/
which execute the launcher app with the right argument. May be there
is not a great step towards what you are looking for, and it gets rid
of dependencies to OS.
regards,
--
Arnaud Bailly, Dr. - Ingénieur de Recherche
NORSYS
1, rue de la Cense des Raines
ZAC du Moulin
59710 ENNEVELIN
Tel : (33) 3 28 76 56 76
Mob : (33) 6 17 12 19 78
Fax : (33) 3 28 76 57 00
Web : http://www.norsys.fr
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Executing a maven class application
Posted by jerome lacoste <je...@gmail.com>.
On 4/13/06, Kevin Galligan <ma...@kgalligan.com> wrote:
> I was wondering if there is some utility out there for this.
>
> Build a maven jar package for a simple 1-off app. Could be something
> bigger, but basically you want to execute this on the command line. What I
> do now is run assembly with 'jar-with-dependencies' (if that's not exactly
> it, you know what I mean). Then I manually set up my command line with...
>
> java -cp target\whatever-1.0-SNAPSHOT-with-dependencies.jar
> com.package.Apparg0 arg1 ...
>
> The problem here is that you have to have the full path info for the
> classpath, and always have to run the assembly deal. I was thinking one or
> both of two things.
>
> mvn-run groupId=com.example.example-app artifactId=example-app
> com.package.App arg0 arg1
>
> The 'mvn-run' code would add to the classpath according to the group and
> package info in the repository.
>
> It might also be possible to add groupId and artifactId as environment
> variables and just run...
>
> mvn-run com.package.App arg0 arg1
>
> Obviously version would be an optional argument.
>
> (I just went and checked the maven bin folder to make sure this exact thing
> wasn't already there)
>
> Ok. The other one. Closely related, but I'm not sure of the value. An
> execute plugin.
>
> mvn exe:exe -DappClass=com.package.App -Dargruments='arg0 arg1'
>
> I've been up really late working, so this might be nonsense, but I know this
> is a common useage patter that I have and it gets clunky because of the
> classpath, etc. Any thoughts?
I use a solution based on assembly + custom generic scripts.
The assembly packages my app into
\lib
\bin
\etc
and the scripts (.sh and .bat) automatically add lib/*.jar to my CLASSPATH
Otherwise, as Emmanuel pointed, the exec plugin might help you.
Configure the plugin in your <build> section and specify your
arguments on the command line using the appropriate property.
Jerome
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Executing a maven class application
Posted by Emmanuel Venisse <em...@venisse.net>.
You can look at exec plugin in mojo project : http://mojo.codehaus.org/exec-maven-plugin/
Emmanuel
Kevin Galligan a écrit :
> I was wondering if there is some utility out there for this.
>
> Build a maven jar package for a simple 1-off app. Could be something
> bigger, but basically you want to execute this on the command line. What I
> do now is run assembly with 'jar-with-dependencies' (if that's not exactly
> it, you know what I mean). Then I manually set up my command line with...
>
> java -cp target\whatever-1.0-SNAPSHOT-with-dependencies.jar
> com.package.Apparg0 arg1 ...
>
> The problem here is that you have to have the full path info for the
> classpath, and always have to run the assembly deal. I was thinking one or
> both of two things.
>
> mvn-run groupId=com.example.example-app artifactId=example-app
> com.package.App arg0 arg1
>
> The 'mvn-run' code would add to the classpath according to the group and
> package info in the repository.
>
> It might also be possible to add groupId and artifactId as environment
> variables and just run...
>
> mvn-run com.package.App arg0 arg1
>
> Obviously version would be an optional argument.
>
> (I just went and checked the maven bin folder to make sure this exact thing
> wasn't already there)
>
> Ok. The other one. Closely related, but I'm not sure of the value. An
> execute plugin.
>
> mvn exe:exe -DappClass=com.package.App -Dargruments='arg0 arg1'
>
> I've been up really late working, so this might be nonsense, but I know this
> is a common useage patter that I have and it gets clunky because of the
> classpath, etc. Any thoughts?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org