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>


2009/7/1 olip <[email protected]>:
>
> Hi everyone!
> Maybe you can help me out with this.
>
> I want to build a executable jar file which must contain a war file within
> (because I have included a jetty server runner in it). Problem is if I use
> the predefined assembly descriptor to build it:
> <descriptorRef>jar-with-dependencies</descriptorRef> in my main pom
>
> the war file will not get copied into it.
>
> If I write my own descriptor e.g.:
> -------
> <assembly>
>  <id>jar-with-all-dependencies</id>
>  <formats>
>    <format>jar</format>
>  </formats>
>  <includeBaseDirectory>false</includeBaseDirectory>
>  <dependencySets>
>    <dependencySet>
>        <unpack>true</unpack>
>        <scope>runtime</scope>
>
>        <unpackOptions>
>            <excludes>
>                <!--this doesnt work 100%....war file gets unpacked all the
> time in the jar too...i dont know why-->
>                <exclude>*:war</exclude>
>            </excludes>
>        </unpackOptions>
>
>    </dependencySet>
>
>      <dependencySet>
>          <unpack>false</unpack>
>        <scope>runtime</scope>
>            <includes>
>              <include>*:war:*</include>
>
>            </includes>
>      </dependencySet>
>
>
>  </dependencySets>
>  <fileSets>
>    <fileSet>
>      <directory>${project.build.outputDirectory}</directory>
>    </fileSet>
>  </fileSets>
> </assembly>
>
> ------
> the war file gets included but if I try to run the jar it cant find the main
> class so if I extract it the directory structure is messed up e.g.
> executable class is not in root folder but in target/classes
>
> Also if I use the standard jar-with-dependencies descriptor code seen here:
> http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html
>
> which is:
> ------
> <assembly>
>  <id>jar-with-dependencies</id>
>  <formats>
>    <format>jar</format>
>  </formats>
>  <includeBaseDirectory>false</includeBaseDirectory>
>  <dependencySets>
>    <dependencySet>
>      <unpack>true</unpack>
>      <scope>runtime</scope>
>    </dependencySet>
>  </dependencySets>
>  <fileSets>
>    <fileSet>
>      <directory>${project.build.outputDirectory}</directory>
>    </fileSet>
>  </fileSets>
> </assembly>
> -----
>
> it cant find the main class also it should be the same result as just using
>  <descriptorRef>jar-with-dependencies</descriptorRef>
>
> in my main pom.
>
> I am using maven2.
>
> Thank you for your help
> --
> View this message in context: 
> http://www.nabble.com/Using-custom-assembly-descriptor-tp24290434p24290434.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