Which archive formats can dependencies:unpack-dependencies
unpack? For instance, as far as I see it can't unpack RPM packages. Is there a list of formats it supports available somewhere? Is there some trick with which I can make maven unpack RPM package?
The Maven Dependency Plugin uses internally Plexus Archiver to archive and unarchive files. As of today, version 2.10 of the maven-dependency-plugin
depends on version 2.9 of plexus-archiver
.
Plexus components are configured with the help of a META-INF/plexus/components.xml
file. In the case of the Dependency Plugin, you can see this file in the source code and it declares unarchiver for the following extensions: zip
, jar
, war
, ear
, swc
, nar
, esb
, sar
, car
, par
, rar
. They all use the same ZipUnArchiver
component, meaning they are all extracted as if they were ZIP files.
Plexus Archiver 2.9 also comes with its set of predefined unarchiver, and it adds: bzip2
, gzip
, tar
, tgz
, tar.gz
, tbz2
, tar.bz2
to the list. Latest version also adds snappy
and xz
files.
If you want to be able to unpack a custom extension, you will need to create a new project capable of unpacking it and register it as a Plexus component. For RPM packages, you can create a rpm-archiver
Maven project and have the following inside META-INF/plexus/components.xml
:
<component-set>
<components>
<component>
<role>org.codehaus.plexus.archiver.UnArchiver</role>
<role-hint>rpm</role-hint>
<implementation>class.able.to.unpack.rpm.packages</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
</component>
</components>
</component-set>
where class.able.to.unpack.rpm.packages
is the fully classified name of your custom class able to unpack RPM files. This class must implement the interface org.codehaus.plexus.archiver.UnArchiver
, but to simplify, you can make this class inherit from org.codehaus.plexus.archiver.AbstractUnArchiver
. All you need to do is then override the execute()
and execute(path, outputDirectory)
methods. The former needs to extract the file retrieved by getSourceFile()
into the directory retrieved by getDestDirectory()
, while the latter only extract the specified path
inside the source file into the given outputDirectory
.
After compiling and installing this new project, you can add it as a dependency to the maven-dependency-plugin
:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<!-- rest of your configuration -->
<dependencies>
<dependency>
<groupId>my.archiver</groupId>
<artifactId>rpm-archiver</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
</plugin>
This way, when the plugin runs, it will know how to unpack files having the rpm
extension, and will use the class you configured in components.xml
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments