The Export Maven Plugin is an Apache Maven plugin designed for exporting an entire Maven project into a .zip file. It respects the .gitignore
settings and, regardless of .gitignore
, always omits the build directory (target
).
Typically, archiving a project involves the following command:
git archive -o export.zip HEAD
However, in teaching environments, particularly when instructing large groups in Java, it's not always feasible to assume that Git is installed on all systems. In scenarios where Git is not part of the course curriculum, and lab/homework submissions are required in .zip format, it's important to ensure that students' submissions do not include unwanted files, such as those in the build folder or IDE-specific directories.
Since students are expected to use Maven and create their projects via homework-quickstart archetype, this simple plugin enables students to automatically export their projects in the required format without including unwanted files.
To use the plugin, insert the following configuration into the plugins section of your pom.xml:
<plugin>
<groupId>org.atp-fivt</groupId>
<artifactId>export-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<zipFileName>Name_Surname.zip</zipFileName>
</configuration>
</plugin>
The zipFileName
parameter allows you to specify the desired name for the zip file. By default, the file name is set to export.zip.
To run the plugin, execute:
mvn export:export
The resulting .zip
file will be located in the target directory.
This plugin leverages the jGit library to compile a list of all files in the project, adhering to the rules specified in .gitignore
files. Importantly, the functionality of this plugin does not require Git to be installed on the target machine. This is particularly beneficial in educational settings or environments where Git installation cannot be assumed. By using jGit, the plugin operates independently of the local Git installation.