Search code examples
mavenpluginsmaven-assembly-plugin

instructing maven assembly plugin to unpack thirdparty jar which is not defined as dependency in pom.xml


Using maven-assembly-plugin I am able to create a *.jar with my project specific requirements. It unpacks all dependencies and transitive dependencies. But along with that I have a third party jar which is not there in maven repository. That is referenced locally in my project. Is there a way to instruct maven-assembly-plugin to unpack given jar file as well?

my jar creating assembly descriptor is:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  <id>packing-jar</id>  
  <formats>
    <format>jar</format>
  </formats>

  <includeBaseDirectory>false</includeBaseDirectory>

  <fileSets>
    <fileSet>
        <directory>${project.build.outputDirectory}/com</directory>
        <outputDirectory>/com</outputDirectory>
    </fileSet>
  </fileSets>

  <dependencySets>
    <dependencySet>
        <outputDirectory>/</outputDirectory>
        <unpack>true</unpack>
        <useProjectArtifact>false</useProjectArtifact>
    </dependencySet>
  </dependencySets>
</assembly>

Solution

  • As my requirement needs to unpack only one third party jar I tried a turnaround for that. Used maven install to install that jar locally. So, as that jar is now part of maven dependencies that assembly plugin will unpack it.