Skip to content

Instantly share code, notes, and snippets.

@frobs
Created March 13, 2014 09:02
Show Gist options
  • Save frobs/9524766 to your computer and use it in GitHub Desktop.
Save frobs/9524766 to your computer and use it in GitHub Desktop.
Packaging with maven .tar.gz .tar.bz2 .zip
<!--See:https://maven.apache.org/plugins/maven-assembly-plugin/component.html-->
<assembly>
<formats>
<format>tar.gz</format>
<!--<format>tar.bz2</format>-->
<!--<format>zip</format>-->
</formats>
<fileSets>
<fileSet>
<directory>target/libs</directory>
<outputDirectory>bin/libs</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>target</directory>
<outputDirectory>bin</outputDirectory>
<includes>
<include>basex-collection-*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>basex-collection</groupId>
<artifactId>basex-collection</artifactId>
<name>basex-collection</name>
<version>0.0.1</version>
<repositories>
<repository>
<id>basex</id>
<name>BaseX Maven Repository</name>
<url>http://files.basex.org/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.basex</groupId>
<artifactId>basex</artifactId>
<version>7.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--This plugin modify the manifest inside the .jar-->
<!--Contain the main class and the claspath-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>main</mainClass>
<classpathPrefix>libs/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<!--This plugin copy all the dependencies to the specified path-->
<!--{project.build.directory} is the directory where maven work-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/libs/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--This plugin compress all your resources into your release distributable-->
<!--The files that you want compress inside your distributable is specified in a bin.xml file-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>assembly/bin.xml</descriptor>
<finalName>${pom.name}-${pom.version}</finalName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment