You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by nambi sankaran <sn...@yahoo.com> on 2009/06/02 08:20:55 UTC
War Plugin does not copy Main-Class to / of war file
Hi All
I am trying to embed jetty into a war file, so that the war file becomes executable.
java -jar mywar.war
will start jetty on port 8080. ie, Main-Class will start Jetty programmatically.
To achieve this I have added configuration section for war plugin,
<build>
<finalName>testwar</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>TestMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
This results in correct MANIFEST.MF file, with the following entry
Main-Class : TestMain
Howvever, TestMain class is coped to WEB-INF/classes directory
To make the war executable, the TestMain should be at the root level of war file.
The war plugin documentation doesn't provide enough information how to configure the plugin, to copy "Main-Class" to root level.
Have anyone come across this issue?
Thanks
Nambi
Re: War Plugin does not copy Main-Class to / of war file
Posted by Kalle Korhonen <ka...@gmail.com>.
You can do it in a single module. Since a self-executable war is
non-standard, the war plugin doesn't know that a main class should be
in the root. Here's how I do it:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>move-main-class</id>
<phase>compile</phase>
<configuration>
<tasks>
<move
todir="${project.build.directory}/${project.artifactId}">
<fileset dir="${project.build.directory}/classes/">
<include name="MyWebApp*.class" />
</fileset>
</move>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Kalle
On Mon, Jun 1, 2009 at 11:33 PM, Stephen Connolly
<st...@gmail.com> wrote:
> You'll probably want to put your main class in a separate jar and then use
> dependency:unpack-dependencies to unpack the main class
>
> 2009/6/2 nambi sankaran <sn...@yahoo.com>
>
>> Hi All
>>
>> I am trying to embed jetty into a war file, so that the war file becomes
>> executable.
>> java -jar mywar.war
>> will start jetty on port 8080. ie, Main-Class will start Jetty
>> programmatically.
>>
>> To achieve this I have added configuration section for war plugin,
>>
>> <build>
>> <finalName>testwar</finalName>
>> <plugins>
>> <plugin>
>> <groupId>org.apache.maven.plugins</groupId>
>> <artifactId>maven-war-plugin</artifactId>
>> <configuration>
>> <archive>
>> <manifest>
>> <mainClass>TestMain</mainClass>
>> </manifest>
>> </archive>
>> </configuration>
>> </plugin>
>> </plugins>
>> </build>
>>
>>
>> This results in correct MANIFEST.MF file, with the following entry
>> Main-Class : TestMain
>>
>> Howvever, TestMain class is coped to WEB-INF/classes directory
>> To make the war executable, the TestMain should be at the root level of war
>> file.
>>
>> The war plugin documentation doesn't provide enough information how to
>> configure the plugin, to copy "Main-Class" to root level.
>>
>> Have anyone come across this issue?
>>
>> Thanks
>> Nambi
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: War Plugin does not copy Main-Class to / of war file
Posted by Stephen Connolly <st...@gmail.com>.
You'll probably want to put your main class in a separate jar and then use
dependency:unpack-dependencies to unpack the main class
2009/6/2 nambi sankaran <sn...@yahoo.com>
> Hi All
>
> I am trying to embed jetty into a war file, so that the war file becomes
> executable.
> java -jar mywar.war
> will start jetty on port 8080. ie, Main-Class will start Jetty
> programmatically.
>
> To achieve this I have added configuration section for war plugin,
>
> <build>
> <finalName>testwar</finalName>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <archive>
> <manifest>
> <mainClass>TestMain</mainClass>
> </manifest>
> </archive>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
>
> This results in correct MANIFEST.MF file, with the following entry
> Main-Class : TestMain
>
> Howvever, TestMain class is coped to WEB-INF/classes directory
> To make the war executable, the TestMain should be at the root level of war
> file.
>
> The war plugin documentation doesn't provide enough information how to
> configure the plugin, to copy "Main-Class" to root level.
>
> Have anyone come across this issue?
>
> Thanks
> Nambi
>
>