maven-dependency-plugin (goals “copy-dependencies”, “unpack”) is not supported by m2e

前端 未结 8 957
一个人的身影
一个人的身影 2020-12-02 03:59

I have a fairly simple Maven project:


    
        ...
    
         


        
相关标签:
8条回答
  • 2020-12-02 04:38

    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>
    
    0 讨论(0)
  • 2020-12-02 04:38

    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.

    0 讨论(0)
  • 2020-12-02 04:38

    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.

    0 讨论(0)
  • 2020-12-02 04:42

    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>
    
    0 讨论(0)
  • 2020-12-02 04:51

    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.

    0 讨论(0)
  • 2020-12-02 04:55

    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

    0 讨论(0)
提交回复
热议问题