OH! I didn't know about the addClasspath, addExtensions, and classpathPrefix settings for the manfest configuration in the maven-jar-plugin! And to think it was so easy. Now I feel stupid.
Thanks very much, Lee and Tim, and merci boucoup Jean-Laurent!!!! --Erik -----Original Message----- From: jean-laurent de morlhon [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 31, 2006 5:09 PM To: Maven Users List Subject: Re: Stand-alone app Erik, If I understand what you want to do clearly, you can do everything without writing a plugin. Just use the maven-jar-plugin and maven-assembly-plugin. The following is extracted from a standalone application I built with m2 a few month ago (assembly plugin as slightly changed since then and spurts some deprecation but it works fine) First make a executable jar and putting all dependencies into the manifest is done this way : <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>com.foo.bar.ClassHoldingAMainMethod</mainClass> <addClasspath>true</addClasspath> <addExtensions>true</addExtensions> <classpathPrefix>./lib/</classpathPrefix> </manifest> </archive> </configuration> </plugin> Note that classpathPrefix is ./lib, of course you can use whatever you want. call the assembly plugin (plugin is not bound to any phase you can do it if you want) <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptor>assembly.xml</descriptor> </configuration> </plugin> put in the assembly.xml the following : <assembly> <id>distribution</id> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <includes> <include>readme.txt</include> </includes> </fileSet> <fileSet> <directory>target</directory> <outputDirectory></outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> </fileSets> <dependencySets> <dependencySet> <outputDirectory>/lib</outputDirectory> <unpack>false</unpack> <scope>runtime</scope> </dependencySet> </dependencySets> </assembly> then call mvn assembly:directory. you'll find in the target directory the resulting jar and in the lib directory all the dependencies. No plugin code, all is proper declaration. hope it helps. On 5/31/06, Lee Meador <[EMAIL PROTECTED]> wrote: > What I do is build the executable jar. It takes two options to the jar > plugin to put the dependent jar references in the manifest and to put > ./lib on the front of each reference. > > Then I have an assembly that puts that jar and its dependency jars all > together in a zip or tar.gz that will extract into place to run. There > are some properties files too. The assembly xml file is 40 lines. Most > of them just define what goes inside. The rest has mostly to do with > filtering the resouces for different deployment environments. > > The pom has a few lines to tell it to do the assembly as part of a > full build. > > If I didn't do the properties files the way I do it would all run just > fine with 'java -jar ...". As is, I run from the command line without > change after extracting from the zip or tar.gz. > > I'm probably missing something but there isn't that much to configure > and any plugin would need the information about what to put in the > jar, what to filter and so forth. > > On 5/31/06, Midtskogen, Erik <[EMAIL PROTECTED]> wrote: > > > > OK, so it seems that it's not possible to manage the build of a > > stand-alone, desktop application entirely in Maven without resorting > > to one or more hacks or manual processes. I find it rather odd that > > the most basic of all use-cases usually fulfilled by software build > > systems is not yet supported by Maven. But I'm willing to try my > > hand at writing a plugin or goal to fulfill this need and give > > something back to the Maven community. > > > > Just to recap my earlier inquiry, what I'm looking for is a goal > > whose resulting artifact is an executable jar file along with all > > the dependencies it needs in order to run. The goal would > > automatically make the appropriate entries into the artifact jar's > > manifest.mf for the main class and the jar file dependencies. Then, > > it would copy the dependency jar files themselves from the > > repository to the locations specified in the manifest.mf. > > > > Would anybody else here have a need for such a goal, or am I the > > only one using Maven to build stand-alone Java apps? If other > > people would find such a goal useful, should I try to write it as a > > goal of the assembly plugin, with the idea that I could submit it to > > a committer and have it become a goal called, for example, > > assembly:stand-alone-app? > > > > Any feedback or tips would be great--especially from someone who has > > written a Maven goal before. > > > > Thanks, > > --Erik > > > > > > ******************************************************************** > > *************** > > The information in this email (including any attachments) is confidential > > and may be legally privileged. Access to this e-mail by anyone other than > > the intended addressee is unauthorized. If you are not the intended > > recipient of this message, any review, disclosure, copying, distribution, > > retention, or any action taken or omitted to be taken in reliance on it > > (including any attachments) is prohibited and may be unlawful. If you are > > not the intended recipient, please reply to or forward a copy of this > > message to the sender and delete the message, all attachments, and any > > copies thereof from your system and destroy any printout thereof. > > > > ____________________________________________________________________ > > __ > > The information in this email (including any attachments) is confidential > > and may be legally privileged. Access to this e-mail by anyone other than > > the intended addressee is unauthorized. If you are not the intended > > recipient of this message, any review, disclosure, copying, distribution, > > retention, or any action taken or omitted to be taken in reliance on it > > (including any attachments) is prohibited and may be unlawful. If you are > > not the intended recipient, please reply to or forward a copy of this > > message to the sender and delete the message, all attachments, and any > > copies thereof from your system and destroy any printout thereof. > > > > > > -- > -- Lee Meador > Sent from gmail. My real email address is [EMAIL PROTECTED] > > -- Jean-Laurent --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] *********************************************************************************** The information in this email (including any attachments) is confidential and may be legally privileged. Access to this e-mail by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it (including any attachments) is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, all attachments, and any copies thereof from your system and destroy any printout thereof. ______________________________________________________________________ The information in this email (including any attachments) is confidential and may be legally privileged. Access to this e-mail by anyone other than the intended addressee is unauthorized. If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it (including any attachments) is prohibited and may be unlawful. If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, all attachments, and any copies thereof from your system and destroy any printout thereof. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]