You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Eric Wang <je...@gmail.com> on 2006/12/04 17:52:57 UTC
Including an assembly as part of another assembly
Hi, I'm new to Maven so forgive me if this something really obvious. I
looked through the assembly plugin documentation and searched the
archives, but couldn't find anything covering my use case.
I'm building an assembly using the built-in "jar-with-dependencies"
descriptor. That works great. I'd like to include the generated
assembly inside another custom assembly. The custom assembly would be
a zip file containing my jar (generated with the
"jar-with-dependencies" descriptor) along with some other supporting
files located in my project root folder.
Is something like this possible? I've tried messing around with my
custom descriptor, but to no avail. I can generate the zip file, but
it doesn't contain my jar, only the supporting files. If I'm going in
the wrong direction with this, I'd appreciate if someone could let me
know. Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Including an assembly as part of another assembly
Posted by Eric Wang <je...@gmail.com>.
Our projects are indeed pretty much the same. You just chose to
package it differently than I did (or am trying to).
In your case, you have your dependencies as separate jars. I used the
the jar-with-dependencies descriptor to pack everything into a single
jar.
Unfortunately, I can't seem to get Maven to package up my application
along with it's supporting files the way I want to, so I may just
change my application to use multiple jar files as well.
I appreciate your help with this problem Alexander.
On 12/4/06, Alexander Sack <pi...@gmail.com> wrote:
> Eric, I have the eXACT same project. My command line tool needs a couple of
> runtime dependencies.
>
> Let me show how I organize a project which works for me beautifully (maybe
> this will help):
>
> <dependencies>
> <dependency>
> <groupId>acme-depedency-1</groupId>
> <artifactId>acme-dpendency-1</artifactId>
> <version>acme-dependency-1</version>
> </dependency>
> ..
> ..
> ..
> </dependencies>
> <build>
> <plugins>
> <plugin>
> <artifactId>maven-compiler-plugin</artifactId>
> <groupId>org.apache.maven.plugins</groupId>
> <configuration>
> <source>1.5</source>
> <target>1.5</target>
> </configuration>
> </plugin>
> <plugin>
> <artifactId>maven-assembly-plugin</artifactId>
> <version>2.0-beta-1</version>
> <configuration>
> <descriptor>src/main/assembly/acme-assembly.xml</descriptor>
> <outputDirectory>target</outputDirectory>
> <workDirectory>target/assembly/work</workDirectory>
> <finalName>Acme</finalName>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-jar-plugin</artifactId>
> <configuration>
> <archive>
> <manifest>
> <addClasspath>true</addClasspath>
> <mainClass>com.acme.main.class</mainClass>
> </manifest>
> </archive>
> <jarName>acme.jar</jarName>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> That creates the JAR file that I need to put in my application zip file to
> distribute. It also adds the runtime dependencies to my manifest.
>
> Then in my acme-assembly.xml:
>
> <assembly>
> <id>1.0</id>
> <formats>
> <format>tar.gz</format>
> </formats>
> <includeBaseDirectory>false</includeBaseDirectory>
> <fileSets>
> <fileSet>
> <directory>target</directory>
> <outputDirectory></outputDirectory>
> <includes>
> <include>*.jar</include>
> </includes>
> </fileSet>
> <fileSet>
> <outputDirectory></outputDirectory>
> <directory>dist</directory>
> <includes>
> <include>*</include>
> </includes>
> </fileSet>
> </fileSets>
> <dependencySets>
> <dependencySet>
> <outputDirectory>/</outputDirectory>
> <unpack>false</unpack>
> <scope>runtime</scope>
> </dependencySet>
> </dependencySets>
> </assembly>
>
> The dependencySets tag adds the runtime libraries to the root of my
> tar.gzfile so when someone deploys it in a install directory, the
> classpath
> manifest entry is relative to the current path and everything just works.
> When I do mvn package, I get a Acme-1.0.tar.gz with a acme.jar in it a long
> with all of its runtime dependencies. I ALSO in "dist" have a bunch of
> other static files (think license, README, etc.) that gets picked up as
> well.
>
> Not sure if this is the absolute best way or only way, but this works for me
> every time no hassles!
>
> Let me know,
>
> -aps
>
> On 12/4/06, Eric Wang <je...@gmail.com> wrote:
> >
> > Does your jar have any dependencies? If not, then your case is a
> > little bit different from mine.
> >
> > My (maybe not so simple) command line application depends on two jars.
> > If I just run "mvn package" I get a jar in the target directory like
> > you. However that jar doesn't include my application's two
> > dependencies. I have to distribute them separately in order to run my
> > application.
> >
> > The assembly plugin's jar-with-dependencies descriptor seems designed
> > to solve this problem by generating a self-contained jar containing
> > all dependencies. I want to leverage this to generate a self-contained
> > jar, and then zip that jar up along with various support files
> > (readme, etc.).
> >
> > The approach I'm trying right now is to use the provided
> > jar-with-dependencies descriptor along a custom descriptor. My pom
> > looks something like this:
> >
> > <artifactId>maven-assembly-plugin</artifactId>
> > <configuration>
> > <descriptorRefs>
> > <descriptorRef>jar-with-dependencies</descriptorRef>
> > </descriptorRefs>
> > <descriptors>
> > <descriptor>my-custom-descriptor.xml</descriptor>
> > </descriptors>
> > </configuration>
> >
> > My custom descriptor is similar to yours. The problem is when I enter
> > "mvn assembly:assembly" my custom descriptor is always processed
> > first, before the jar-with-dependencies descriptor. Naturally, the
> > self-contained jar doesn't exist yet, and I end up with a zip file
> > full of support files, but no jar.
> >
> > In a sense, my custom descriptor depends on the jar-with-dependencies
> > descriptor being run first, but I have no idea how to express this. I
> > will look into creating multiple modules to see if it will solve my
> > problem, however it seems somewhat overkill for my application.
> >
> > Thanks for your help Alexander.
> >
> >
> > On 12/4/06, Alexander Sack <pi...@gmail.com> wrote:
> > > I won't speak for best practices but typically you would create another
> > > module to do the packaging (similar to some of the EAR examples).
> > >
> > > For a simple command-line application, my guess is one pom and one
> > assembly
> > > descriptor will be enough. For my command-line tool I generate the jar
> > and
> > > then assemble the whole applicaiton like so:
> > >
> > > snippet from my assembly descriptor XML file:
> > >
> > > <fileSets>
> > > <fileSet>
> > > <directory>target</directory>
> > > <outputDirectory></outputDirectory>
> > > <includes>
> > > <include>*.jar</include>
> > > </includes>
> > > </fileSet>
> > > <fileSet>
> > > <outputDirectory></outputDirectory>
> > > <directory>dist</directory>
> > > <includes>
> > > <include>*</include>
> > > </includes>
> > > </fileSet>
> > > </fileSets>
> > >
> > > Basically dist has some extra static files in it, target is where the
> > JAR
> > > gets built, and then the assembly plugin builds everything together.
> > >
> > >
> > > -aps
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> "What lies behind us and what lies in front of us is of little concern to
> what lies within us." -Ralph Waldo Emerson
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Including an assembly as part of another assembly
Posted by Alexander Sack <pi...@gmail.com>.
Eric, I have the eXACT same project. My command line tool needs a couple of
runtime dependencies.
Let me show how I organize a project which works for me beautifully (maybe
this will help):
<dependencies>
<dependency>
<groupId>acme-depedency-1</groupId>
<artifactId>acme-dpendency-1</artifactId>
<version>acme-dependency-1</version>
</dependency>
..
..
..
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.0-beta-1</version>
<configuration>
<descriptor>src/main/assembly/acme-assembly.xml</descriptor>
<outputDirectory>target</outputDirectory>
<workDirectory>target/assembly/work</workDirectory>
<finalName>Acme</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.acme.main.class</mainClass>
</manifest>
</archive>
<jarName>acme.jar</jarName>
</configuration>
</plugin>
</plugins>
</build>
That creates the JAR file that I need to put in my application zip file to
distribute. It also adds the runtime dependencies to my manifest.
Then in my acme-assembly.xml:
<assembly>
<id>1.0</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>target</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<outputDirectory></outputDirectory>
<directory>dist</directory>
<includes>
<include>*</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
The dependencySets tag adds the runtime libraries to the root of my
tar.gzfile so when someone deploys it in a install directory, the
classpath
manifest entry is relative to the current path and everything just works.
When I do mvn package, I get a Acme-1.0.tar.gz with a acme.jar in it a long
with all of its runtime dependencies. I ALSO in "dist" have a bunch of
other static files (think license, README, etc.) that gets picked up as
well.
Not sure if this is the absolute best way or only way, but this works for me
every time no hassles!
Let me know,
-aps
On 12/4/06, Eric Wang <je...@gmail.com> wrote:
>
> Does your jar have any dependencies? If not, then your case is a
> little bit different from mine.
>
> My (maybe not so simple) command line application depends on two jars.
> If I just run "mvn package" I get a jar in the target directory like
> you. However that jar doesn't include my application's two
> dependencies. I have to distribute them separately in order to run my
> application.
>
> The assembly plugin's jar-with-dependencies descriptor seems designed
> to solve this problem by generating a self-contained jar containing
> all dependencies. I want to leverage this to generate a self-contained
> jar, and then zip that jar up along with various support files
> (readme, etc.).
>
> The approach I'm trying right now is to use the provided
> jar-with-dependencies descriptor along a custom descriptor. My pom
> looks something like this:
>
> <artifactId>maven-assembly-plugin</artifactId>
> <configuration>
> <descriptorRefs>
> <descriptorRef>jar-with-dependencies</descriptorRef>
> </descriptorRefs>
> <descriptors>
> <descriptor>my-custom-descriptor.xml</descriptor>
> </descriptors>
> </configuration>
>
> My custom descriptor is similar to yours. The problem is when I enter
> "mvn assembly:assembly" my custom descriptor is always processed
> first, before the jar-with-dependencies descriptor. Naturally, the
> self-contained jar doesn't exist yet, and I end up with a zip file
> full of support files, but no jar.
>
> In a sense, my custom descriptor depends on the jar-with-dependencies
> descriptor being run first, but I have no idea how to express this. I
> will look into creating multiple modules to see if it will solve my
> problem, however it seems somewhat overkill for my application.
>
> Thanks for your help Alexander.
>
>
> On 12/4/06, Alexander Sack <pi...@gmail.com> wrote:
> > I won't speak for best practices but typically you would create another
> > module to do the packaging (similar to some of the EAR examples).
> >
> > For a simple command-line application, my guess is one pom and one
> assembly
> > descriptor will be enough. For my command-line tool I generate the jar
> and
> > then assemble the whole applicaiton like so:
> >
> > snippet from my assembly descriptor XML file:
> >
> > <fileSets>
> > <fileSet>
> > <directory>target</directory>
> > <outputDirectory></outputDirectory>
> > <includes>
> > <include>*.jar</include>
> > </includes>
> > </fileSet>
> > <fileSet>
> > <outputDirectory></outputDirectory>
> > <directory>dist</directory>
> > <includes>
> > <include>*</include>
> > </includes>
> > </fileSet>
> > </fileSets>
> >
> > Basically dist has some extra static files in it, target is where the
> JAR
> > gets built, and then the assembly plugin builds everything together.
> >
> >
> > -aps
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
"What lies behind us and what lies in front of us is of little concern to
what lies within us." -Ralph Waldo Emerson
Re: Including an assembly as part of another assembly
Posted by Eric Wang <je...@gmail.com>.
Does your jar have any dependencies? If not, then your case is a
little bit different from mine.
My (maybe not so simple) command line application depends on two jars.
If I just run "mvn package" I get a jar in the target directory like
you. However that jar doesn't include my application's two
dependencies. I have to distribute them separately in order to run my
application.
The assembly plugin's jar-with-dependencies descriptor seems designed
to solve this problem by generating a self-contained jar containing
all dependencies. I want to leverage this to generate a self-contained
jar, and then zip that jar up along with various support files
(readme, etc.).
The approach I'm trying right now is to use the provided
jar-with-dependencies descriptor along a custom descriptor. My pom
looks something like this:
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<descriptors>
<descriptor>my-custom-descriptor.xml</descriptor>
</descriptors>
</configuration>
My custom descriptor is similar to yours. The problem is when I enter
"mvn assembly:assembly" my custom descriptor is always processed
first, before the jar-with-dependencies descriptor. Naturally, the
self-contained jar doesn't exist yet, and I end up with a zip file
full of support files, but no jar.
In a sense, my custom descriptor depends on the jar-with-dependencies
descriptor being run first, but I have no idea how to express this. I
will look into creating multiple modules to see if it will solve my
problem, however it seems somewhat overkill for my application.
Thanks for your help Alexander.
On 12/4/06, Alexander Sack <pi...@gmail.com> wrote:
> I won't speak for best practices but typically you would create another
> module to do the packaging (similar to some of the EAR examples).
>
> For a simple command-line application, my guess is one pom and one assembly
> descriptor will be enough. For my command-line tool I generate the jar and
> then assemble the whole applicaiton like so:
>
> snippet from my assembly descriptor XML file:
>
> <fileSets>
> <fileSet>
> <directory>target</directory>
> <outputDirectory></outputDirectory>
> <includes>
> <include>*.jar</include>
> </includes>
> </fileSet>
> <fileSet>
> <outputDirectory></outputDirectory>
> <directory>dist</directory>
> <includes>
> <include>*</include>
> </includes>
> </fileSet>
> </fileSets>
>
> Basically dist has some extra static files in it, target is where the JAR
> gets built, and then the assembly plugin builds everything together.
>
>
> -aps
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Including an assembly as part of another assembly
Posted by Alexander Sack <pi...@gmail.com>.
I won't speak for best practices but typically you would create another
module to do the packaging (similar to some of the EAR examples).
For a simple command-line application, my guess is one pom and one assembly
descriptor will be enough. For my command-line tool I generate the jar and
then assemble the whole applicaiton like so:
snippet from my assembly descriptor XML file:
<fileSets>
<fileSet>
<directory>target</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<outputDirectory></outputDirectory>
<directory>dist</directory>
<includes>
<include>*</include>
</includes>
</fileSet>
</fileSets>
Basically dist has some extra static files in it, target is where the JAR
gets built, and then the assembly plugin builds everything together.
-aps
On 12/4/06, Eric Wang <je...@gmail.com> wrote:
>
> My project is a simple command-line application. I didn't think it
> required multiple modules so I never looked into that. Is that the
> preferred way to accomplish what I'm describing? Basically, I just
> want to include my assembly jar along with a few other files inside a
> zip file.
>
>
> On 12/4/06, Alexander Sack <pi...@gmail.com> wrote:
> > Quick question, why can't you have two sub modules under your POM, one
> that
> > generates an assembly, the other generating the final output with the
> other
> > assembly included? (you get the idea)
> >
> > -aps
> >
> > On 12/4/06, Eric Wang <je...@gmail.com> wrote:
> > >
> > > Hi, I'm new to Maven so forgive me if this something really obvious. I
> > > looked through the assembly plugin documentation and searched the
> > > archives, but couldn't find anything covering my use case.
> > >
> > > I'm building an assembly using the built-in "jar-with-dependencies"
> > > descriptor. That works great. I'd like to include the generated
> > > assembly inside another custom assembly. The custom assembly would be
> > > a zip file containing my jar (generated with the
> > > "jar-with-dependencies" descriptor) along with some other supporting
> > > files located in my project root folder.
> > >
> > > Is something like this possible? I've tried messing around with my
> > > custom descriptor, but to no avail. I can generate the zip file, but
> > > it doesn't contain my jar, only the supporting files. If I'm going in
> > > the wrong direction with this, I'd appreciate if someone could let me
> > > know. Thanks.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >
> >
> > --
> > "What lies behind us and what lies in front of us is of little concern
> to
> > what lies within us." -Ralph Waldo Emerson
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
"What lies behind us and what lies in front of us is of little concern to
what lies within us." -Ralph Waldo Emerson
Re: Including an assembly as part of another assembly
Posted by Eric Wang <je...@gmail.com>.
My project is a simple command-line application. I didn't think it
required multiple modules so I never looked into that. Is that the
preferred way to accomplish what I'm describing? Basically, I just
want to include my assembly jar along with a few other files inside a
zip file.
On 12/4/06, Alexander Sack <pi...@gmail.com> wrote:
> Quick question, why can't you have two sub modules under your POM, one that
> generates an assembly, the other generating the final output with the other
> assembly included? (you get the idea)
>
> -aps
>
> On 12/4/06, Eric Wang <je...@gmail.com> wrote:
> >
> > Hi, I'm new to Maven so forgive me if this something really obvious. I
> > looked through the assembly plugin documentation and searched the
> > archives, but couldn't find anything covering my use case.
> >
> > I'm building an assembly using the built-in "jar-with-dependencies"
> > descriptor. That works great. I'd like to include the generated
> > assembly inside another custom assembly. The custom assembly would be
> > a zip file containing my jar (generated with the
> > "jar-with-dependencies" descriptor) along with some other supporting
> > files located in my project root folder.
> >
> > Is something like this possible? I've tried messing around with my
> > custom descriptor, but to no avail. I can generate the zip file, but
> > it doesn't contain my jar, only the supporting files. If I'm going in
> > the wrong direction with this, I'd appreciate if someone could let me
> > know. Thanks.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> "What lies behind us and what lies in front of us is of little concern to
> what lies within us." -Ralph Waldo Emerson
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Including an assembly as part of another assembly
Posted by Alexander Sack <pi...@gmail.com>.
Quick question, why can't you have two sub modules under your POM, one that
generates an assembly, the other generating the final output with the other
assembly included? (you get the idea)
-aps
On 12/4/06, Eric Wang <je...@gmail.com> wrote:
>
> Hi, I'm new to Maven so forgive me if this something really obvious. I
> looked through the assembly plugin documentation and searched the
> archives, but couldn't find anything covering my use case.
>
> I'm building an assembly using the built-in "jar-with-dependencies"
> descriptor. That works great. I'd like to include the generated
> assembly inside another custom assembly. The custom assembly would be
> a zip file containing my jar (generated with the
> "jar-with-dependencies" descriptor) along with some other supporting
> files located in my project root folder.
>
> Is something like this possible? I've tried messing around with my
> custom descriptor, but to no avail. I can generate the zip file, but
> it doesn't contain my jar, only the supporting files. If I'm going in
> the wrong direction with this, I'd appreciate if someone could let me
> know. Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
"What lies behind us and what lies in front of us is of little concern to
what lies within us." -Ralph Waldo Emerson