Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-dependency-plugin:unpack Error

I'm trying to extract some .exe files from a dependency jar file and put them under ${project.build.directory}/classes/.

But when I execute:

mvn clean compile dependency:unpack

I get:

Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:unpack (default-cli) on project simple: Either artifact or artifactItems is required -> [Help 1

I have verified that the dependencies are available in my local repository.

In my example pom below I've used junit as an example, but no matter which dependency I list, I get the same error.

pom.xml:

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.10</version>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>package</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>4.10</version>
                  <type>jar</type>
                  <overWrite>false</overWrite>
  <outputDirectory>${project.build.directory}/classes/externaltools</outputDirectory>                   
                  <includes>**/*.txt</includes>
                </artifactItem>
              </artifactItems>   
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </pluginManagement>
</build>
like image 526
PistolPete Avatar asked May 15 '15 11:05

PistolPete


People also ask

What is unpack in maven?

org.apache.maven.plugins:maven-dependency-plugin:3.3.0:unpack. Description: Goal that retrieves a list of artifacts from the repository and unpacks them in a defined location.

What does maven dependency plugin do?

The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.

What is maven download plugin?

This is a plugin meant to help maven user to download different files on different protocol in part of maven build. The plugin caches downloaded files in maven cache directory, which saves network trafic and speedup build.

What is maven Assembly plugin?

The Assembly Plugin for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files. Your project can easily build distribution "assemblies" using one of the prefabricated assembly descriptors.


1 Answers

The issue is due to you cannot use mvn clean compile dependency:unpack and <executions> tags together.

In documentation Maven Depdendency Plugin at the bottom part of the page you can read:

If you intend to configure this mojo for execution on the command line using: mvn dependency:unpack you must not put the configuration inside the executions tag. Your configuration should look like this:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.10</version>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>[ groupId ]</groupId>
              <artifactId>[ artifactId ]</artifactId>
              <version>[ version ]</version>
              <type>[ packaging ]</type>
              <classifier> [classifier - optional] </classifier>
              <overWrite>[ true or false ]</overWrite>
              <outputDirectory>[ output directory ]</outputDirectory>
              <destFileName>[ filename ]</destFileName>
              <includes>[ comma separated list of file filters ]</includes>
              <excludes>[ comma separated list of file filters ]</excludes>
            </artifactItem>
          </artifactItems>
          <!-- other configurations here -->
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

I have tried removing the <execution> tags and works perfectly!

like image 124
King Midas Avatar answered Sep 22 '22 04:09

King Midas