On Wed, Nov 26, 2008 at 10:22 AM, CheapLisa <[EMAIL PROTECTED]> wrote:
>
> Does anyone have an *end-to-end* example (with files you can send or attach)
> that will allow me to create a single jar with all dependencies using maven?

This is more than just the assembly.
Setting the MANIFEST.MF correctly with Class-Path is the jar plugin's job.

See http://maven.apache.org/shared/maven-archiver/examples/classpath.html

> In the end I want to be able to:
>  $cd dist
>  $java -jar patch-main.jar

We are doing this.

You need to setup both maven-jar-plugin and maven-assembly-plugin.

I copy all my dependencies into the lib/ directory of the binary
bundle and always include the config/ on the classpath so that I can
include files like log4j.properties, spring configs, etc so the
admin/user can customize the files outside of jars.

Here are snippets from the files you need.

------------------------ pom.xml --------------------------
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
          <executions>
            <execution>
              <id>assembly:package</id>
              <phase>package</phase>
              <goals>
                <!--
                  Work around for http://jira.codehaus.org/browse/MASSEMBLY-97
                  as the goal should be attached.
                -->
                <goal>single</goal>
              </goals>
              <configuration>
                <descriptors>
                  <descriptor>src/main/assembly/bin.xml</descriptor>
                </descriptors>
              </configuration>
            </execution>
          </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>your.fully.qalified.MainClassname</mainClass>
            </manifest>
            <manifestEntries>
              <Class-Path>config/</Class-Path>
            </manifestEntries>
            <manifest>
              <addClasspath>true</addClasspath>
              <classpathPrefix>lib/</classpathPrefix>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
---------------------------------------------------------------------


------------------------ src/main/assembly/bin.xml --------------------------
<assembly>
  <id>bin</id>
  <formats>
    <format>dir</format>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>true</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>src/main/config</directory>
      <outputDirectory>config/</outputDirectory>
      <includes>
        <include>*</include>
      </includes>
      <excludes>
        <exclude>CVS</exclude>
      </excludes>
    </fileSet>
    <fileSet>
      <directory>target</directory>
      <outputDirectory></outputDirectory>
      <includes>
        <include>${artifactId}-${version}.jar</include>
      </includes>
    </fileSet>
  </fileSets>
  <files>
    <file>
      <source>src/main/scripts/start_debug.bat</source>
      <filtered>true</filtered>
    </file>
    <file>
      <source>src/main/scripts/start.bat</source>
      <filtered>true</filtered>
    </file>
    <file>
      <source>src/main/scripts/stop.bat</source>
      <filtered>true</filtered>
    </file>
    <file>
      <source>src/main/scripts/start.sh</source>
      <filtered>true</filtered>
      <fileMode>0744</fileMode>
    </file>
    <file>
      <source>src/main/scripts/stop.sh</source>
      <filtered>true</filtered>
      <fileMode>0744</fileMode>
    </file>
  </files>
  <dependencySets>
    <dependencySet>
      <outputDirectory>lib</outputDirectory>
      <unpack>false</unpack>
    </dependencySet>
  </dependencySets>
</assembly>
---------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to