Hi Tim,

Hi Tim.  Yes, I'm using the assembly plugin to copy the dependencies
into a subdirectory called "./lib", and I'm using the jar plugin to
build the executable jar, and actually everything works basically OK.
My only problem is that the jar plugin is adding the dependency jar
files into the executable artifact jar.  These are unnecessary and only
increase the size of executable jar file.  There is no way I've found to
put a jarred jar library onto the classpath without writing extra code
in your executable to support this.  The jar libraries need to reside
outside the executable jar in the normal filesystem to be easily
accessible.

For now, I'm just removing the unneeded dependency jars from the
executable jar manually, but I'm curious how one might go about
configuring jar:jar so that it properly configures the manifest.mf
without also rolling the dependency jars into its artifact.

Here is my POM:

<project xmlns="http://maven.apache.org/POM/4.0.0"; 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd";>
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.galaxyusa.pairfinder</groupId>
        <artifactId>pairfinder</artifactId>
        <packaging>jar</packaging>
        <version>0.9</version>
        <name>Maven Quick Start Archetype</name>
        <url>http://maven.apache.org</url>
        <dependencies>
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>3.8.1</version>
                        <scope>test</scope>
                </dependency>

                <dependency>
                        <groupId>org.skroople</groupId>
                        <artifactId>skroople</artifactId>
                        <version>0.7</version>
                </dependency>

        </dependencies>

        <build>
                <pluginManagement>
                        <plugins>
                                <plugin>
        
<groupId>org.apache.maven.plugins</groupId>
        
<artifactId>maven-compiler-plugin</artifactId>
                                        <version>2.0</version>
                                        <configuration>
                                                <source>1.5</source>
                                                <target>1.5</target>
                                        </configuration>
                                </plugin>

                                <plugin>
        
<groupId>org.apache.maven.plugins</groupId>
        
<artifactId>maven-jar-plugin</artifactId>
                                        <configuration>
                                                <archive>
                                                        <manifest>
        
<mainClass>com.galaxyusa.pairfinder.PairFinder</mainClass>
        
<addClasspath>true</addClasspath>
        
<classpathPrefix>lib</classpathPrefix>
                                                        </manifest>
                                                </archive>
                                        </configuration>
                                </plugin>
                                
                                <plugin>
        
<groupId>org.apache.maven.plugins</groupId>
        
<artifactId>maven-assembly-plugin</artifactId>
                                        <configuration>
                                                <descriptors>
        
<descriptor>src/main/assembly/stand-alone-app.xml</descriptor>
                                                </descriptors>
                                        </configuration>
                                </plugin>
                        </plugins>
                </pluginManagement>
        </build>
</project>

The assembly configuration descriptor is this:

<assembly>
        <id>stand-alone-app</id>
        <formats>
                <format>zip</format>
        </formats>
        <fileSets>
                <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>

Note: this project has a number of transitive dependencies that come
through the dependency for "skroople".

So far, it's still feeling to me like there should be a goal in the
assembly plugin that handles building a standalone app and optionally
zips it up into a zip file or tarball, depending on the platform.  It
could even have sensible defaults such that if you're happy enough with
a stand-alone app set up the way I'm doing it here, (with the jar
library dependencies copied into ./lib) all you would have to do is tell
it what your main class is, and then type "mvn
assembly:stand-alone-app", and you're done.

Yes, I can see that it is possible to accomplish this if you configure
the jar:jar and the assembly:assembly goals just so, and also roll your
own assembly configuration descriptor.  But that seems like more work
than should be necessary for such basic functionality.  Maven is
supposed to make the most common tasks easy to do.

I have looked into the OneJar project.  I can't remember exactly why I
didn't get into it, but I seem to remember that it was a bit intrusive.
You had to write some special code to support it or something like that.
Having all the dependencies inside the same jar is the main point of
OneJar, but that objective isn't all that important to me.  I'm happy
enough just to have the dependencies sitting outside the main
executable.

So, I will start reading about how to write Maven goals and see if I can
come up with something easy to use.  If I'm successful, then maybe the
Maven folks would accept my goal and include it in the assembly plugin.
One can dream...

Vielen Dank!
--Erik

-----Original Message-----
From: Tim Kettler [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 02, 2006 1:11 AM
To: Maven Users List
Subject: Re: Stand-alone app


Hi,

I think my suggestion regarding the use of the dependency-maven-plugin
could have been a 
little bit confusing/misleading. Did you configure it to copy the
dependencies somewhere 
under your target/classes folder? I wanted to mention the OneJar project

(http://one-jar.sourceforge.net/) for this usecase but somewhow forgot.

If you use the assembly-plugin to build your distribution you probably
won't need the 
dependency-plugin at all. Do you use it? If not: Can you post your pom
so that we can have 
a look at it to figure out what is going wrong?

-Tim

Midtskogen, Erik schrieb:
> Hi Tim and Jean-Laurant,
> 
> Thanks so much for your suggestions.  I'm very close now, but I'm 
> still confused about a couple of things.
> 
> After following your suggestions, the jar:jar now adds the correct 
> manifest.mf settings and pulls the correct dependencies out of the 
> repository.  Bravo!!  But the problem is that it is jarring up the 
> dependency jars into the executable jar file itself instead of adding 
> them to a subdirectory in the file system.  When I run the 
> assembly:assembly goal, it does add the jar files to the zip file in 
> the correct location, so my app does work when you unzip it and run 
> it.  No complaints there.  But I'd rather not duplicate the jar 
> entries into the executable jar file, because it almost doubles the 
> size of my distributable.
> 
> Why would one want dependency jar files jarred into the executable jar

> anyway?  I'm confused.  It doesn't seem that Java is able to place 
> such a jarred dependency onto the classpath without special coding in 
> the app itself to do this.  You're supposed to run your executable in 
> one jar file, and keep your library dependencies as separate jar 
> files, no?  Am I wrong about this?  Is there any way of suppressing 
> the addition of the dependencies from being added to the executable 
> jar during the package lifecycle (jar:jar), while still adding the 
> dependency classpath entries into the manifest.mf?
> 
> Thanks!
> --Erik
> 

[...]

---------------------------------------------------------------------
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]

Reply via email to