First you want a jetty-helper module.  This will depend on all the
jetty jars and have the jetty main class:

<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";

    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>

    <modelVersion>4.0.0</modelVersion>



    <groupId>____</groupId>

    <artifactId>jetty-helper</artifactId>


    <version>1-SNAPSHOT</version>

    <name>Helper module for making executable war files using jetty</name>



    <properties>

        <jetty-version>6.1.16</jetty-version>

    </properties>



    <dependencies>

        <dependency>

            <groupId>org.mortbay.jetty</groupId>

            <artifactId>jetty</artifactId>

            <version>${jetty-version}</version>

            <scope>provided</scope>

        </dependency>

        <dependency>

            <groupId>org.mortbay.jetty</groupId>

            <artifactId>jetty-util</artifactId>

            <version>${jetty-version}</version>

            <scope>provided</scope>

        </dependency>

        <dependency>

            <groupId>org.mortbay.jetty</groupId>

            <artifactId>jetty-management</artifactId>

            <version>${jetty-version}</version>

            <scope>provided</scope>

        </dependency>

        <dependency>

            <groupId>org.mortbay.jetty</groupId>

            <artifactId>jetty-plus</artifactId>

            <version>${jetty-version}</version>

            <type>jar</type>

            <scope>provided</scope>

        </dependency>

        <dependency>

            <groupId>org.mortbay.jetty</groupId>

            <artifactId>jetty-naming</artifactId>

            <version>${jetty-version}</version>

            <type>jar</type>

            <scope>provided</scope>

            <exclusions>

                <!-- if you can figure out how to solve the issues
with the class sealing in activation, you can remove the following
exclusion -->
                <exclusion>

                    <groupId>javax.activation</groupId>

                    <artifactId>activation</artifactId>

                </exclusion>

            </exclusions>

        </dependency>

        <dependency>

            <groupId>junit</groupId>

            <artifactId>junit</artifactId>

            <scope>test</scope>

        </dependency>

        <!-- if you want to provide a JSVC support class, you need the
following -->
        <dependency>

            <groupId>commons-daemon</groupId>

            <artifactId>commons-daemon</artifactId>

            <version>1.0.1</version>

        </dependency>

    </dependencies>



    <build>

        <plugins>

            <plugin>

                <artifactId>maven-jar-plugin</artifactId>

                <configuration>

                    <archive>

                        <manifest>

                            <addClasspath>false</addClasspath>

                            <mainClass>___.jetty.Main</mainClass>

                        </manifest>

                    </archive>

                </configuration>

            </plugin>

            <plugin>

                <artifactId>maven-dependency-plugin</artifactId>

                <executions>

                    <execution>

                        <phase>generate-resources</phase>

                        <goals>

                            <goal>unpack-dependencies</goal>

                        </goals>

                        <configuration>

                            <includeScope>provided</includeScope>


<outputDirectory>${project.build.outputDirectory}</outputDirectory>

                        </configuration>

                    </execution>

                </executions>

            </plugin>

        </plugins>

    </build>



</project>


you then add your jetty.Main class, and optionally your JSVC commons
daemon class to this module

Then you have your web app as normal

Then you have another module to give you the executable war file.  You
may be able to optimize this... I have not tried as I need a
non-executable war file as well as an executable war file...

here's the pom for the executable war file... it has no src directory

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd";
         xmlns="http://maven.apache.org/POM/4.0.0";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
    <modelVersion>4.0.0</modelVersion>

    <groupId>____</groupId>
    <artifactId>war-executable</artifactId>
    <version>1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>Executable WAR</name>

    <dependencies>
        <dependency>
            <groupId>____</groupId>
            <artifactId>jetty-helper</artifactId>
            <version>1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>____</groupId>
            <artifactId>___real war file___</artifactId>
            <version>1-SNAPSHOT</version>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>___.jetty.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeTypes>jar</includeTypes>

<outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>



2009/9/23 Stephen Connolly <[email protected]>:
> I'll see if I can share a bit more specific code...
>
>
>
> 2009/9/23 zedros <[email protected]>:
>>
>> hi
>>
>> I did lioke stephenconnolly suggested (see under for the details or the
>> previous mail in the thread), but my java -jar foo.war gives me :
>> Exception in thread "main" java.lang.NoClassDefFoundError: boot/JettyMain
>> Caused by: java.lang.ClassNotFoundException: boot.JettyMain
>>        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>        at java.security.AccessController.doPrivileged(Native Method)
>>        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>>        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>> Could not find the main class: boot.JettyMain. Program will exit.
>>
>> My manifest says Main-Class: boot.JettyMain and this main class is to be
>> found under /WEB-INF/classes/boot/JettyMain.class.
>>
>> Any suggestion on how to resolve this ?
>>
>> thanks in advance
>> zedros
>>
>> This will give you an executable war file, i.e.
>>
>> java -jar foo.war
>>
>> which does what you want
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/xsd/maven-4.0.0.xsd";
>>         xmlns="http://maven.apache.org/POM/4.0.0";
>>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>>    <modelVersion>4.0.0</modelVersion>
>>
>>    <groupId>____</groupId>
>>    <artifactId>____</artifactId>
>>    <packaging>war</packaging>
>>
>>    <dependencies>
>>       <!-- your dependencies... don't forget jetty  -->
>>    </dependencies>
>>
>>    <build>
>>        <plugins>
>>            <plugin>
>>                <artifactId>maven-war-plugin</artifactId>
>>                <configuration>
>>                    <archive>
>>                        <manifest>
>>                            <mainClass>your.package.JettyMain</mainClass>
>>                        </manifest>
>>                    </archive>
>>                </configuration>
>>            </plugin>
>>            <plugin>
>>                <artifactId>maven-dependency-plugin</artifactId>
>>                <executions>
>>                    <execution>
>>                        <phase>generate-resources</phase>
>>                        <goals>
>>                            <goal>unpack-dependencies</goal>
>>                        </goals>
>>                        <configuration>
>>                            <includeTypes>jar</includeTypes>
>>
>> <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
>>                        </configuration>
>>                    </execution>
>>                </executions>
>>            </plugin>
>>        </plugins>
>>    </build>
>> </project>
>>
>>
>>
>> --
>> View this message in context: 
>> http://n2.nabble.com/Using-custom-assembly-descriptor-tp3189204p3699241.html
>> Sent from the maven users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to