156

I have a fairly simple Maven project:

<project>
    <dependencies>
        ...
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/dependencies</outputDirectory>
                        </configuration>    
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

However, I get the following error in m2eclipse:

Description Resource    Path    Location    Type
maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e. pom.xml  /jasperreports-test line 60 Maven Project Build Lifecycle Mapping Problem

Why do I care if m2eclipse doesn't "support" this task? Maven does, and that's all I really care about. How can I get this error in my project to go away?

Tuna
  • 2,937
  • 4
  • 37
  • 61
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411

8 Answers8

164

It seems to be a known issue. You can instruct m2e to ignore this.

Option 1: pom.xml

Add the following inside your <build/> tag:

<pluginManagement>
<plugins>
    <!-- Ignore/Execute plugin execution -->
    <plugin>
        <groupId>org.eclipse.m2e</groupId>
        <artifactId>lifecycle-mapping</artifactId>
        <version>1.0.0</version>
        <configuration>
            <lifecycleMappingMetadata>
                <pluginExecutions>
                    <!-- copy-dependency plugin -->
                    <pluginExecution>
                        <pluginExecutionFilter>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-dependency-plugin</artifactId>
                            <versionRange>[1.0.0,)</versionRange>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                        </pluginExecutionFilter>
                        <action>
                            <ignore />
                        </action>
                    </pluginExecution>
                </pluginExecutions>
            </lifecycleMappingMetadata>
        </configuration>
    </plugin>
   </plugins></pluginManagement>

You will need to do Maven... -> Update Project Configuration on your project after this.

Read more: http://wiki.eclipse.org/M2E_plugin_execution_not_covered#m2e_maven_plugin_coverage_status

Option 2: Global Eclipse Override

To avoid changing your POM files, the ignore override can be applied to the whole workspace via Eclipse settings.

Save this file somewhere on the disk: https://gist.github.com/maksimov/8906462

In Eclipse/Preferences/Maven/Lifecycle Mappings browse to this file and click OK:

Eclipse Settings

maksimov
  • 5,792
  • 1
  • 30
  • 38
  • 10
    What if copy-dependencies is a vital step in building your WAR file? I am working with monstrosity the call m2Eclipse and even if changing the action to execute, the vital files are not copied to the target folder... – bartv Jul 25 '12 at 22:12
  • 1
    For auto-generated ignore settings, @PhoneTech, m2e adds the comment *"This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself."* Not sure what that means though, as you're saying things don't get copied for you. – Arjan Aug 24 '12 at 09:58
  • 6
    Yes, it helped... but that's an awful lot of code to just get rid of a warning :P – dokaspar Mar 08 '13 at 16:35
  • This still gives me a warning, but the error is gone. – stevecross Jun 26 '14 at 12:01
58

This is a problem of M2E for Eclipse M2E plugin execution not covered.

To solve this problem, all you got to do is to map the lifecycle it doesn't recognize and instruct M2E to execute it.

You should add this after your plugins, inside the build. This will remove the error and make M2E recognize the goal copy-depencies of maven-dependency-plugin and make the POM work as expected, copying dependencies to folder every time Eclipse build it. If you just want to ignore the error, then you change <execute /> for <ignore />. No need for enclosing your maven-dependency-plugin into pluginManagement, as suggested before.

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mapping</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <versionRange>[2.0,)</versionRange>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
              </pluginExecutionFilter>
              <action>
                <execute />
              </action>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </plugins>
</pluginManagement>
Caio Cunha
  • 23,326
  • 6
  • 78
  • 74
  • 4
    This solves it indeed. And I was being stupid, thinking when people were talking about moving `` into `` one should actually move the `org.apache.maven.plugins maven-dependency-plugin` in there. But it's about the `org.eclipse.m2e lifecycle-mapping` that needs to be enclosed in ``. When using Quick Fix in Eclipse, the same is added *above* the regular ``, and it seems that location works fine too. Key is then to change `` into ``. Nice. – Arjan Aug 24 '12 at 12:55
  • 1
    Found I needed false within execute as recommended on the link you provided. Thanks for the answer set me on the right path. – cyber-monk Nov 14 '12 at 23:02
  • There is no need to add this AFTER your `plugins` inside the `build`, you can add this before. – Fagner Brack Apr 08 '14 at 04:36
38

If copy-dependencies, unpack, pack, etc., are important for your project you shouldn't ignore it. You have to enclose your <plugins> in <pluginManagement> tested with Eclipse Indigo SR1, maven 2.2.1

user311174
  • 1,738
  • 1
  • 18
  • 17
  • 4
    Thanks, it also helps in Eclipse Indigo SR2 – stemm Jun 09 '12 at 08:36
  • 1
    I'm a bit lost... Does that mean using the code above but with `` instead of ``? Thanks! – xverges Jul 03 '12 at 15:35
  • 1
    Care to explain a bit more? Just putting a `` into `` but still referencing it to do its job, still gives me the same warning. – Arjan Aug 24 '12 at 09:56
  • @CaioToOn, maybe you know some more...? After adding it to `` I still need to add a "regular" 2 line `...` as well, referencing the one as configured in ``, right? (Still seeing Juno complain about the same thing, when in ``.) – Arjan Aug 24 '12 at 10:04
  • @Arjan you should enclose your `plugins` tag with `pluginManagement`. But take a look at the answer I gave below, http://stackoverflow.com/a/12109018/179138 . The suggested one ignores the execution, but don't execute the plugin on Eclipse. – Caio Cunha Aug 24 '12 at 12:01
17

To make it work, instead of ignoring it, you can install the m2e connector for the maven-dependency-plugin:
https://github.com/ianbrandt/m2e-maven-dependency-plugin

Here is how you would do it in Eclipse:

  1. go to Window/Preferences/Maven/Discovery/
  2. enter Catalog URL: http://download.eclipse.org/technology/m2e/discovery/directory-1.4.xml
  3. click Open Catalog
  4. choose the m2e-maven-dependency-plugin
  5. enjoy
mario
  • 323
  • 3
  • 8
  • 1
    +1 for the RIGHT answer. Just remember make a small edit to the `pom.xml` file after installing the plugin, otherwise the error might not go away. – Fagner Brack May 02 '15 at 14:44
  • In Eclipse Luna the Catalog URL is http://download.eclipse.org/technology/m2e/discovery/directory-1.5.xml – jansohn Jul 07 '15 at 12:50
  • I tried this but the Catalog URL fields is not editable! Mine is set to : http://download.eclipse.org/technology/m2e/discovery/directory.xml (i.e. without the -1.4) at the end. Any ideas, how/where one could adjust that? – mmo Jul 25 '16 at 08:18
8

Despite answer from CaioToOn above, I still had problems getting this to work initially.

After multiple attempts, finally got it working. Am pasting my final version here - hoping it will benefit somebody else.

    <build> 
        <plugins>
            <!--
            Copy all Maven Dependencies (-MD) into libMD/ folder to use in classpath via shellscript
             --> 
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/libMD</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <!--  
        Above maven-dependepcy-plugin gives a validation error in m2e. 
        To fix that, add the plugin management step below. Per: http://stackoverflow.com/a/12109018
        -->
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-dependency-plugin</artifactId>
                                        <versionRange>[2.0,)</versionRange>
                                        <goals>
                                            <goal>copy-dependencies</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
SGB
  • 2,118
  • 6
  • 28
  • 35
1

I had the same problem when trying to load Hadoop project in eclipse. I tried the solutions above, and I believe it might have worked in Eclipse Kepler... not even sure anymore (tried too many things).

With all the problems I was having, I decided to move on to Eclipse Luna, and the solutions above did not work for me.

There was another post that recommended changing the ... tag to package. I started doing that, and it would "clear" the errors... However, I start to think that the changes would bite me later - I am not an expert on Maven.

Fortunately, I found out how to remove all the errors. Go to Window->Preferences->Maven-> Error/Warnings and change "Plugin execution not covered by lifecycle..." option to "Ignore". Hope it helps.

Myluco
  • 59
  • 3
0

I know this is old post but I struggled today with this problem also and I used template from this page: http://maven.apache.org/plugins/maven-dependency-plugin/usage.html

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>copy</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <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>
                </artifactItem>
              </artifactItems>
              <!-- other configurations here -->
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

and everything works fine under m2e 1.3.1.

When I tried to use

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/dependencies</outputDirectory>
                    </configuration>    
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

I also got m2e error.

Andna
  • 6,539
  • 13
  • 71
  • 120
  • Yes, this is exactly the purpose of this entry : m2e now requires _connectors_ to map plugins executions in Eclipse build lifecycle.
    Even at the time of my comment writing, m2e only supports a few such connectors : you have to use the `lifecycle-mapping` Maven plugin to instruct m2e how to deal with an unsupported plugin (here the `maven-dependency-plugin`)
    – Olivier B. May 30 '13 at 21:02
0

Another option is to navigate to problems tab, right click on error, click apply quick fix. The should generate the ignore xml code and apply it .pom file for you.

blue-sky
  • 51,962
  • 152
  • 427
  • 752