You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Paul G <ps...@googlemail.com> on 2007/07/23 22:15:24 UTC

Packaging a release of a jar with dependencies

I would like to know the best way to create a release artifact such as a zip
which contains my jar file along with all it's dependency jars in a bin
directory of the zip. I have used the assembly plugin to create wars with
external configs files and docs. But have not found any easy examples of how
to package a jar. I know you can copy all the dependencies to a destination
folder with the dependency plug in, does that mean I am looking at using the
dependency and assembly plug in together attached to the packaing phase to
achieve what I want?
-- 
View this message in context: http://www.nabble.com/Packaging-a-release-of-a-jar-with-dependencies-tf4132165s177.html#a11751868
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Packaging a release of a jar with dependencies

Posted by Paul G <ps...@googlemail.com>.
Thanks for that Andrew, looks like what I was thinking I would have to do,
thanks once again for saving me a couple of hours of trying to work it.

Cheers

Paul

Andrew Boyer wrote:
> 
> Paul,
> 
> I used the dependency and assembly plugins.  Something like:
> 
> <plugin>
>   <artifactId>maven-assembly-plugin</artifactId>
>   <configuration>
>     <descriptors>
>       <descriptor>src/main/assembly/dist.xml</descriptor>
>     </descriptors>
>   </configuration>
> </plugin>
> <plugin>
>   <artifactId>maven-dependency-plugin</artifactId>
>   <executions>
>     <execution>
> 	<id>copy-dependencies</id>
> 	<phase>package</phase>
> 	<goals>
> 	  <goal>copy-dependencies</goal>
> 	</goals>
> 	<configuration>
> 	  <outputDirectory>${basedir}/target/dist/lib</outputDirectory>
>         <includeScope>runtime</includeScope>
> 	  <overWriteIfNewer>true</overWriteIfNewer>
> 	</configuration>
>     </execution>
>   </executions>
> </plugin>
> 
> With the following assembly descriptor:
> 
> <assembly>
>   <id>dist</id>
>   <formats>
>     <format>zip</format>
>     <format>tar.gz</format>
>   </formats>
>   <includeBaseDirectory>false</includeBaseDirectory>
>   <fileSets>
>     <fileSet>
>       <directory>target/dist</directory>
>       <outputDirectory>/</outputDirectory>
>       <excludes>
>         <exclude>*tests.jar</exclude>
>       </excludes>
>     </fileSet>
>   </fileSets>
> </assembly>
> 
> Hope that helps.
> 
> Andrew
>> -----Original Message-----
>> From: Paul G [mailto:ps.grove@googlemail.com]
>> Sent: Monday, July 23, 2007 4:15 PM
>> To: users@maven.apache.org
>> Subject: Packaging a release of a jar with dependencies
>> 
>> 
>> I would like to know the best way to create a release artifact such as
> a
>> zip
>> which contains my jar file along with all it's dependency jars in a
> bin
>> directory of the zip. I have used the assembly plugin to create wars
> with
>> external configs files and docs. But have not found any easy examples
> of
>> how
>> to package a jar. I know you can copy all the dependencies to a
>> destination
>> folder with the dependency plug in, does that mean I am looking at
> using
>> the
>> dependency and assembly plug in together attached to the packaing
> phase to
>> achieve what I want?
>> --
>> View this message in context:
> http://www.nabble.com/Packaging-a-release-
>> of-a-jar-with-dependencies-tf4132165s177.html#a11751868
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Packaging-a-release-of-a-jar-with-dependencies-tf4132165s177.html#a11753298
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Packaging a release of a jar with dependencies

Posted by Andrew Boyer <ab...@Endeca.com>.
Paul,

I used the dependency and assembly plugins.  Something like:

<plugin>
  <artifactId>maven-assembly-plugin</artifactId>
  <configuration>
    <descriptors>
      <descriptor>src/main/assembly/dist.xml</descriptor>
    </descriptors>
  </configuration>
</plugin>
<plugin>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
	<id>copy-dependencies</id>
	<phase>package</phase>
	<goals>
	  <goal>copy-dependencies</goal>
	</goals>
	<configuration>
	  <outputDirectory>${basedir}/target/dist/lib</outputDirectory>
        <includeScope>runtime</includeScope>
	  <overWriteIfNewer>true</overWriteIfNewer>
	</configuration>
    </execution>
  </executions>
</plugin>

With the following assembly descriptor:

<assembly>
  <id>dist</id>
  <formats>
    <format>zip</format>
    <format>tar.gz</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>target/dist</directory>
      <outputDirectory>/</outputDirectory>
      <excludes>
        <exclude>*tests.jar</exclude>
      </excludes>
    </fileSet>
  </fileSets>
</assembly>

Hope that helps.

Andrew
> -----Original Message-----
> From: Paul G [mailto:ps.grove@googlemail.com]
> Sent: Monday, July 23, 2007 4:15 PM
> To: users@maven.apache.org
> Subject: Packaging a release of a jar with dependencies
> 
> 
> I would like to know the best way to create a release artifact such as
a
> zip
> which contains my jar file along with all it's dependency jars in a
bin
> directory of the zip. I have used the assembly plugin to create wars
with
> external configs files and docs. But have not found any easy examples
of
> how
> to package a jar. I know you can copy all the dependencies to a
> destination
> folder with the dependency plug in, does that mean I am looking at
using
> the
> dependency and assembly plug in together attached to the packaing
phase to
> achieve what I want?
> --
> View this message in context:
http://www.nabble.com/Packaging-a-release-
> of-a-jar-with-dependencies-tf4132165s177.html#a11751868
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org