How can I untar an artifact in maven?
maven, tar
Solution
You can `untar` an artifact by using `dependency:unpack` goal of `maven dependency plugin`. Here is a modified version of the example.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>artifact-groupId</groupId>
<artifactId>the-artifact</artifactId>
<version>a.b</version>
<type>tar</type>
<outputDirectory>${project.build.directory}/artifactLocation</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Problem
How do I untar an artifact to use to compile my source? Do I need to copy the tar file before untarring it? I have something like below... ``` <build> <plugins> <plugin> <artifactId>abcId</artifactId> <version>1</version> <executions> <execution> <id>abc untar</id> <phase>process-resources</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>tar</executable> <workingDirectory>???</workingDirectory> <arguments> <argument>xvf abc.tar</argument> </arguments> </configuration> </execution> </executions> </plugin> </plugins> </build> ```