You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kent Närling <ke...@seamless.se> on 2008/05/30 00:34:36 UTC
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
Re: Creating a nice application package with execution bat+sh files... problem with maven-assembly-plugin?
Posted by Kent Närling <ke...@seamless.se>.
Actually, the "include the world" problem was me having a bad dependency to
some stufff... :-(
Does the shade plugin bundle all classes unpacked inside the jar?
That usually becomes a bit clumsy...
//Kent
2008/5/30 simon.kitching@chello.at <si...@chello.at>:
> Kent Närling schrieb:
> > 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
> >
> >
> I've not seen any problems with maven-assembly-plugin trying to include
> jars used only by maven plugins. Are you sure that's what is happening?
> Running "mvn dependency:tree" will show you what your projects
> dependencies are.
>
> You might also want to look at the maven-shade-plugin. This can generate
> an executable jar for a maven project, with all the necessary
> dependencies bundled within it; very convenient. Unfortunately while the
> plugin is great, the documentation is ****. It doesn't even mention this
> very important feature.
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-shade-plugin</artifactId>
> <version>1.1</version>
> <executions>
> <execution>
> <phase>package</phase>
> <goals>
> <goal>shade</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
>
> Just make sure that the manifest file has a "Main-Class: ..." and all
> works nicely.
>
> Regards,
> Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
Kent Närling
System Developer
SEAMLESS
Dalagatan 100, 8 tr, 113 43 Stockholm, Sweden
Phone: +46 8 5648 7800, fax: +46 8 5648 7823
Mobile: +46 70 836 9925
Mail: kent.narling@seamless.se
www.seamless.se
Re: Creating a nice application package with execution bat+sh files...
problem with maven-assembly-plugin?
Posted by "simon.kitching@chello.at" <si...@chello.at>.
Kent Närling schrieb:
> 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
>
>
I've not seen any problems with maven-assembly-plugin trying to include
jars used only by maven plugins. Are you sure that's what is happening?
Running "mvn dependency:tree" will show you what your projects
dependencies are.
You might also want to look at the maven-shade-plugin. This can generate
an executable jar for a maven project, with all the necessary
dependencies bundled within it; very convenient. Unfortunately while the
plugin is great, the documentation is ****. It doesn't even mention this
very important feature.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
Just make sure that the manifest file has a "Main-Class: ..." and all
works nicely.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Antwort: Creating a nice application package with execution bat+sh files... problem
with maven-assembly-plugin?
Posted by to...@gi-de.com.
"Kent Närling" <ke...@seamless.se>
30.05.2008 07:02
Bitte antworten an
"Maven Users List" <us...@maven.apache.org>
An
users@maven.apache.org
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