How to create a package
Question
A package is a module that comes with several modules. It's very useful to deploy multiple modules at once. Here is a quick how-to that illustrate the repository https://github.com/pvollenweider/package-template. This repository ca be used as a template
Answer
First you need to fork the repository https://github.com/pvollenweider/package-template
Configuration
You need to adapt your modules basic information such artifactId, name, version and description in the pom.xml
<artifactId>package-template</artifactId>
<name>Package Template</name>
<version>1.0.0</version>
<description>This project package my modules</description>
Once it's done, you need to set a few properties used for the manifest and the package name.
<jahia.final.package.name>package-template</jahia.final.package.name>
<jahia.manifest.package.id>package-template</jahia.manifest.package.id>
<jahia.manifest.description>my-module, another-module</jahia.manifest.description>
Then you will need to add as dependencies all modules that you want to package.
In the following example we want to add the following modules:
my-modulefromorg.jahia.modulesin version 1.0.0another-modulefromorg.foo.modulesin version 2.0.0
Note that these 2 modules are released and available in my local repository. If you need to create a package with snapshots, then you have to change the version as needed.
<dependencies>
<dependency>
<groupId>org.jahia.modules</groupId>
<artifactId>my-module</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.foo.modules</groupId>
<artifactId>another-module</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
If your modules have a groupId different from org.jahia.modules, you will need to configure a list of all groupId you want to include, using a includeGroupIds configuration.
For instance, if you have modules with groupId with org.jahia.modules and org.foo.modules then you should set this in both copy-dependencies-sources and copy-dependencies goals:
<includeGroupIds>org.jahia.modules,org.foo.modules</includeGroupIds>
Time to build
To create your package, simply use maven:
mvn install
It's done. If everything went good, your package is available under the target directory.
What's included in this repository?
Here is the content of the pom.xml of this example
<?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>
<parent>
<artifactId>jahia-packages-parent</artifactId>
<groupId>org.jahia.packages</groupId>
<version>8.0.0.0</version>
</parent>
<artifactId>package-template</artifactId>
<name>Package Template</name>
<version>1.0.0</version>
<description>This project package some modules</description>
<packaging>pom</packaging>
<properties>
<jahia.final.package.name>package-template</jahia.final.package.name>
<jahia.manifest.package.id>package-template</jahia.manifest.package.id>
<jahia.manifest.description>my-module, another-module</jahia.manifest.description>
<jahia.package.sources.assembly.file>src/main/assembly/dependencies-sources.xml</jahia.package.sources.assembly.file>
<jahia.package.assembly.file>src/main/assembly/dependencies.xml</jahia.package.assembly.file>
</properties>
<repositories>
<repository>
<id>jahia-public</id>
<name>Jahia Public Repository</name>
<url>https://devtools.jahia.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jahia.modules</groupId>
<artifactId>my-module</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.foo.modules</groupId>
<artifactId>another-module</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${dependency.plugin.version}</version>
<executions>
<execution>
<id>copy-dependencies-sources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>org.jahia.modules,org.foo.modules</includeGroupIds>
<outputDirectory>${project.build.directory}/sources</outputDirectory>
<classifier>sources</classifier>
</configuration>
</execution>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>org.jahia.modules,org.foo.modules</includeGroupIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
And the src/main/assembly/dependencies-sources.xml
<assembly>
<id>root</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>${basedir}/target/sources</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${basedir}/</directory>
<outputDirectory>/META-INF</outputDirectory>
<includes>
<include>*.txt</include>
</includes>
</fileSet>
</fileSets>
</assembly>
And the src/main/assembly/dependencies.xml is very similar
<assembly>
<id>root</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>${basedir}/target/dependency</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${basedir}/</directory>
<outputDirectory>/META-INF</outputDirectory>
<includes>
<include>*.txt</include>
</includes>
</fileSet>
</fileSets>
</assembly>