You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Clifton Craig <cc...@gbg.com> on 2006/05/16 21:51:49 UTC
Running a simple Java project, Maven2
Hello all!
I'm having trouble running a simmple (well moderately simple) project. It
consists of two Groovy defined classes so far and Groovy source loading seems
to not work for some reason. So instead I tried compiling using the Antrun
plugin in Maven. All is well but now I wish to run my code (it's a simple
GUI) to see what it looks like and now I have problems. I can create a jar
using the jar plugin from the command line, "mvn jar:jar" but that doesnot
run through all of the lifecycle phases and only picks up resources. I can
create a jar using "mvn install" and that works ok but I can't seem to define
a Main-Class attribute in my manifest. I've included my custom manifest
definition (MANIFEST.MF) under src/main/resources/META-INF but that doesn't
get included in the jar for some reason. Maven preferrs to generate one for
me no matter what I do. I'm not understanding how to easily get what would be
a straight foward JAva project to execute from the command line using Maven.
In Maven 1 I'm thinking this would be as simple as running "maven jar run"
but I'm not sure how to do the same here. Is there a way I can define the
main class in my pom or in the plugin settings that I'm not aware of? please
advise. Thanx in advance!
---------------------------------------------------
Clifton C. Craig, Software Engineer
Intelligent Computer Systems - A Division of GBG
ccc@icsaward.com
ccraig@gbg.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Running a simple Java project, Maven2
Posted by Clifton Craig <cc...@icsaward.com>.
Hi Markus,
Thanx. That worked out just fine. Only problem was with the assembly plugin
since I couldn't download due to the codehaus outage I wasn't able to use it.
Thanx all the same.
---------------------------------------------------
Clifton C. Craig, Software Engineer
Intelligent Computer Systems - A Division of GBG
ccc@icsaward.com
ccraig@gbg.com
On Wednesday 17 May 2006 3:59 am, Markus Reinhardt wrote:
> Hi Clifton,
>
> Am Dienstag, den 16.05.2006, 15:51 -0400 schrieb Clifton Craig:
> > Is there a way I can define the
> > main class in my pom or in the plugin settings that I'm not aware of?
> > please advise.
>
> there is. Just add
>
> ...
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <configuration>
> <archive>
> <manifest>
> <mainClass>your.mainclass.here.MainClass</mainClass>
> <addClasspath>true</addClasspath>
> </manifest>
> </archive>
> </configuration>
> </plugin>
> ...
> </plugins>
> </build>
> ...
>
> to your pom.xml. Additionally you might take a look at mavens assembly
> plugin:
>
> ...
> <plugin>
> <artifactId>maven-assembly-plugin</artifactId>
> <version>2.1-SNAPSHOT</version>
> <configuration>
> <descriptorRefs>
> <value>jar-with-dependencies</value>
> </descriptorRefs>
> <manifest>
> <mainClass>your.mainclass.here.MainClass</mainClass>
> <addClasspath>true</addClasspath>
> </manifest>
> </configuration>
> </plugin>
> ...
>
> builds a JAR with all dependencies included.
>
> Markus
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Running a simple Java project, Maven2
Posted by Markus Reinhardt <mr...@hygiene.uni-wuerzburg.de>.
Hi Clifton,
Am Dienstag, den 16.05.2006, 15:51 -0400 schrieb Clifton Craig:
> Is there a way I can define the
> main class in my pom or in the plugin settings that I'm not aware of? please
> advise.
there is. Just add
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>your.mainclass.here.MainClass</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
...
</plugins>
</build>
...
to your pom.xml. Additionally you might take a look at mavens assembly plugin:
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<descriptorRefs>
<value>jar-with-dependencies</value>
</descriptorRefs>
<manifest>
<mainClass>your.mainclass.here.MainClass</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</configuration>
</plugin>
...
builds a JAR with all dependencies included.
Markus