"Kent Närling" <[EMAIL PROTECTED]> 
30.05.2008 07:02
Bitte antworten an
"Maven Users List" <[email protected]>


An
[email protected]
Kopie

Thema
Creating a nice application package with execution bat+sh files... problem 
with maven-assembly-plugin?






Hi!

I would like to be able to build a self-sufficient application package 
from
a project into a zip/tar, ie with all dependencies and a prepared scrip to
execute it.

I have so far tried two approches:

A, Using maven-assembly-plugin and creating my own assembly file
    This has two problems:
     1, I have set the dependency scope to runtime, but it still includes
"the whole world"!
         I mean, it even includes a lot of maven jar:s! (which are 
obviously
not necessary to run the app)
     2, It becomes very inconvenient to write the script and manually
updating the jar:s that should be in the classpath... :-(

B, Using the Mojo appassembler-maven-plugin, but this is very buggy... it
even gives me nullpointer exceptions! :-(

Anyone have tips about the best we to achive this?

//Kent

---------------

hi Kent, 

at first we build a jar containing only a MANIFEST.MF by setting in our 
pom.xml:

...
<build>
        <finalName>myStartJarWithManiFest</finalName>
        <plugins>
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <configuration>
                          <archive>
                            <manifest>
                              <addClasspath>true</addClasspath>
                            </manifest>
                          </archive>
                        </configuration>
                </plugin> 

This results to an empty jar with the whole classpath in it.

second, we build an assembly:

                        <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-assembly-plugin</artifactId>
                                <!-- dont use 2.2-beta-2 -->
                                <!-- 
http://jira.codehaus.org/browse/MNG-2456 -->
                                <version>2.2-beta-1</version>
                                <executions>
                                        <execution>
                                                <phase>package</phase>
                                                <configuration>
                                                        <id>my-id</id>
 <workDirectory>build/assembly/</workDirectory>
                                                        <descriptors>
 <descriptor>src/main/assembly/install.xml</descriptor>
                                                        </descriptors>
                                                </configuration>
                                                <goals>
 <goal>attached</goal>
                                                </goals>
                                        </execution>
                                </executions>
                        </plugin>

the assembly is configured to contain 
- the empty jar with the manifest.MF in it
- the scart scripts (*.bat and *.sh)
- the dependent jars

        <fileSets>
                <fileSet>
                        <directory>src/main/install</directory>
                        <outputDirectory></outputDirectory>
                        <includes>
                                <include>**</include>
                        </includes>
                </fileSet>
 
                <fileSet>
                        <directory>target</directory>
                        <outputDirectory>lib</outputDirectory>
                        <includes>
 <include>myStartJarWithManiFest.jar</include>
                        </includes>
                </fileSet>
        </fileSets>
        <dependencySets>
                <dependencySet>
                        <!-- special  outputFileNameMapping, otherwise the 
jars name isnt ${version}-SNAPSHOT.jar, but timestamp.jar -->
                        <!-- 
http://jira.codehaus.org/browse/MASSEMBLY-67-->
                        <!-- http://jira.codehaus.org/browse/MJAR-28-->
                        <!-- http://jira.codehaus.org/browse/MNG-2456-->
 
<outputFileNameMapping>${artifactId}-${baseVersion}.${extension}</outputFileNameMapping>
 
                        <outputDirectory>lib</outputDirectory>
                        <unpack>false</unpack>
                </dependencySet>
        </dependencySets>

the scart scripts than remains very easy, because only the 
myStartJarWithManiFest.jar must be in the classpath.


Torsten

Reply via email to