maven-dependency-plugin:unpack fails in Eclipse

Garret Wilson picture Garret Wilson · Feb 4, 2011 · Viewed 7.6k times · Source

I have a library of JavaScript in dependency globalmentor-core.jar, and I use maven-dependency in another project to transfer the JavaScript to a web directory:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.globalmentor</groupId>
                                <artifactId>globalmentor-core</artifactId>
                                <overWrite>true</overWrite>
                                <outputDirectory>${project.build.outputDirectory}/com/guiseframework/assets/javascript</outputDirectory>
                                <includes>**/*.js</includes>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

That works wonderfully on the command-line. In Eclipse using m2eclipse I get:

2/4/11 5:26:53 AM PST: Build errors for guiseframework; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack (unpack) on project guiseframework: Error unpacking file: R:\java\trunk\globalmentor-core\target\classes to: R:\java\trunk\guiseframework\target\classes\com\guiseframework\assets\javascript
org.codehaus.plexus.archiver.ArchiverException: The source must not be a directory.

The closest thing I can find is http://jira.codehaus.org/browse/MDEP-187, where someone claims they will "provide trivial patch shortly. That was in 2008.

Is there a fix for this, or am I stuck?

Answer

Cutberto picture Cutberto · Oct 6, 2011

I've found a solution/workaround for this problem.

My configuration: Windows XP SP 3, Maven 3, JDK 1.6.0_24, Maven repository under "C:\Documents and Settings\<YOUR_ID>\.m2" folder.

Follow these steps:

  1. Run ‘dir c:\ /X’ and look for the string with ~ in it

    08/01/2011 04:53 PM DOCUME~1          Documents and Settings

  2. Open your settings.xml file and under the <settings> tag add a localRepository tag:
    <localRepository>C:/DOCUME~1/<YOUR_ID>/.m2/repository<\localRepository>

This should make the plugin work. Apparently, maven-dependency-plugin (up to version 2.3) has problems with paths including spaces in it.

Regards,
Cutberto.