Midtskogen, Erik schrieb:
Hi Tim,

Ohhh!  I think I see what's happening.  I was expecting the final result
zip file to appear under the ./target directory instead of right in the
root directory.  After running assembly:assembly there is a zip file
under the ./target directory with a somewhat longer name
"pairfinder-0.9-stand-alone-app.zip", and this zip file is quite large
because it has the redundant copies of the jar files.  I thought this
was the final artifact of the assembly:assembly goal.  I didn't notice
the pairfinder-0.9.zip file sitting right in the root, and this file is
the correct file to distribute the app.  It's exactly what I wanted.

This isn't the result I am getting.

There are two files generated in the target directory: pairfinder-0.9.jar and pairfinder-0.9-stand-alone-app.zip. There is no third file generated in the root directory of the project.

The jar just contains the compiled classes and the manifest with the Class-Path entry. And the zip contains the build artifact and its dependencies... Exactly as wanted.

I have attached the test project I created. Can you try to run 'mvn assembly:assambly' on that and see what it produces for you.


Well, thank you so much!

Even though this jar:jar/assembly:assembly combination does work, I'm
still looking into writing an explicit goal for accomplishing this task.
The fact that lots of people are probably going to want to do this, but
yet it took me (a beginning user, in case you couldn't tell) several
days of fumbling to get it right is an indication that there may be a
need for it.  I agree that It's not difficult to use the jar and
assembly to create a stand-alone build once you understand how to do it.
But I think it could be even easier with a goal.  Even if nobody else
has any need for it, at least I'm learning a lot about how Maven works
by doing it.  And maybe other people would like it, too.  Especially
Maven beginners like me :-)

Do you think I should look into writing it as a goal/mojo under the
assembly plugin, in the hopes that maybe I could submit it to the Maven
Project, or should I write it into my own plugin that I write from
scratch?

As Wayne said, writing a small guide to help other new users seems more 
appropriate.

Thanks so much!
--Erik

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


Just to be sure I understand you correctly: Your problem is that the
dependendcies of your project are included in in the created jar artifact
('pairfinder-0.9.jar')?

I ask this because I can't reproduce your problem with the
pom/descriptor you posted. I just replaced your internal dependency with a dependency to commons-beanutils. When I now run 'mvn assembly:assembly' the artifact is created with the right classpath entries in the manifest and the zip file has the dependencies in the lib directory
???????

Have you tried to run a 'mvn clean' before creating the assembly?

-Tim

Midtskogen, Erik schrieb:
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]




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




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

Reply via email to