Skip to Main Content
Maven: The Definitive Guide
book

Maven: The Definitive Guide

by Sonatype Company
September 2008
Intermediate to advanced content levelIntermediate to advanced
470 pages
14h 22m
English
O'Reilly Media, Inc.
Content preview from Maven: The Definitive Guide

Controlling the Contents of an Assembly

In theory, id and format are the only absolute requirements for a valid assembly descriptor; however, many assembly archivers will fail if they do not have at least one file to include in the output archive. The task of defining the files to be included in the assembly is handled by the five main sections of the assembly descriptor: files, fileSets, dependencySets, repositories, and moduleSets. To explore these sections most effectively, we’ll start by discussing the most elemental section: files. Then, we’ll move onto the two most commonly used sections, fileSets and dependencySets. Once you understand the workings of fileSets and dependencySets, it’s easier to understand repositories and moduleSets.

Files Section

The files section is the simplest part of the assembly descriptor. It is designed for files that have a definite location relative to your project’s directory. Using this section, you have absolute control over the exact set of files that are included in your assembly, exactly what they are named, and where they will reside in the archive. See Example 12-6.

Example 12-6. Including a JAR file in an assembly using files

<assembly>
  ...
  <files>
    <file>
      <source>target/my-app-1.0.jar</source>
      <outputDirectory>lib</outputDirectory>
      <destName>my-app.jar</destName>
      <fileMode>0644</fileMode>
    </file>
  </files>
  ...
</assembly>

Assuming you were building a project called my-app with a version of 1.0, Example 12-6 would include your project’s JAR in ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Apache Maven Cookbook

Apache Maven Cookbook

Raghuram Bharathan
Mastering Apache Maven 3

Mastering Apache Maven 3

Prabath Siriwardena
Learning Apache Maven

Learning Apache Maven

Kevin Bowersox

Publisher Resources

ISBN: 9780596517335Supplemental ContentErrata Page