2015-05-06 3 views
2

Когда я ввожу свой Maven проект в моем затмение, я получаю эту ошибку:Maven-плагин Maven при построении проектов

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:buildnumber-maven-plugin:1.0:create-timestamp (execution: generate-build-number, phase: generate-sources) pom.xml /DataClient line 6 Maven Project

Кто-нибудь знает, как решить эту проблему? Я попробовал несколько других способов, которые были перечислены в SO-вопросах, но это не сработало.

Я использую eclipse kepler, и у меня есть pluginManagement, а также в моем файле pom.xml.

Мой pom.xml фрагмент кода, где я использую плагины

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <configuration> 
        <argLine>-javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/1.7/jmockit-1.7.jar</argLine> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>cobertura-maven-plugin</artifactId> 
       <configuration> 
        <instrumentation> 
         <excludes> 
          <exclude>**/test/**/*.class</exclude> 
         </excludes> 
        </instrumentation> 
        <formats> 
         <format>xml</format> 
         <format>html</format> 
        </formats> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-javadoc-plugin</artifactId> 
       <version>2.9.1</version> 
       <configuration> 
        <author>false</author> 
        <keywords>true</keywords> 
        <show>public</show> 
        <links> 
         <link>http://docs.guava-libraries.googlecode.com/git-history/v16.0/javadoc/</link> 
         <link>http://netty.io/4.0/api/</link> 
        </links> 
        <doctitle>Data Client API (${project.version})</doctitle> 
        <windowtitle>Data Client API (${project.version})</windowtitle> 
        <groups> 
         <group> 
          <title>Core API</title> 
          <packages>com.host.grads.client:com.host.grads.client.resources</packages> 
         </group> 
         <group> 
          <title>Miscellaneous</title> 
          <packages>com.host.grads.client.utils</packages> 
         </group> 
        </groups> 
       </configuration> 
       <executions> 
        <execution> 
         <id>attach-javadocs</id> 
         <goals> 
          <goal>jar</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 
+0

Вы можете скопировать полный pom.xml? Кажется, что плагин 'buildnumber-maven-plugin', участвующий в проблеме, отсутствует в части, которую вы скопировали. Для более позднего сайта 'buildnumber-maven-plugin': http://mojo.codehaus.org/buildnumber-maven-plugin/ – Fabien

+0

По умолчанию правильная версия buildnumber-maven-plugin, потому что, похоже, вы используете крайнюю старую версию из этого. – khmarbaise

+0

@Fabien Это единственные плагины, которые у меня есть в моем '' в моем файле pom.xml. Нужно ли добавлять что-нибудь, чтобы исправить эту проблему? – john

ответ

0

я нашел это на SO, и я думаю, что это ответ на ваш вопрос: Plugin execution not covered by lifecycle configuration (JBossas 7 EAR archetype)

скопировать текст изначально написанный Ян:

This is a "feature" of the M2E plugin that had been introduced a while ago. It's not directly related to the JBoss EAR plugin but also happens with most other Maven plugins.

If you have a plugin execution defined in your pom (like the execution of maven-ear-plugin:generate-application-xml), you also need to add additional config information for M2E that tells M2E what to do when the build is run in Eclipse, e.g. should the plugin execution be ignored or executed by M2E, should it be also done for incremental builds, ... If that information is missing, M2E complains about it by showing the "Plugin execution not covered by lifecycle configuration" error message.

See here for a more detailed explanation and some sample config that needs to be added to the pom to make that error go away:

https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html



Если вам нужно реализовать это решение, вы можете посмотреть на этот комментарий от ранее упомянутого вопроса: https://stackoverflow.com/a/26447353/4810148

Вот копия того, что coderplus ответил. Разумеется, вам придется заменить groupId и artifactId теми плагинами, которые связаны с вашим случаем.

Eclipse has got the concept of incremental builds.This is incredibly useful as it saves a lot of time.

How is this Useful

Say you just changed a single .java file. The incremental builders will be able to compile the code without having to recompile everything(which will take more time).

Now what's the problem with Maven Plugins

Most of the maven plugins aren't designed for incremental builds and hence it creates trouble for m2e. m2e doesn't know if the plugin goal is something which is crucial or if it is irrelevant. If it just executes every plugin when a single file changes, it's gonna take lots of time.

This is the reason why m2e relies on metadata information to figure out how the execution should be handled. m2e has come up with different options to provide this metadata information and the order of preference is as below(highest to lowest)

  1. pom.xml file of the project
  2. parent, grand-parent and so on pom.xml files
  3. [m2e 1.2+] workspace preferences
  4. installed m2e extensions
  5. [m2e 1.1+] lifecycle mapping metadata provided by maven plugin
  6. default lifecycle mapping metadata shipped with m2e

1,2 refers to specifying pluginManagement section in the tag of your pom file or any of it's parents. M2E reads this configuration to configure the project.Below snippet instructs m2e to ignore the jslint and compress goals of the yuicompressor-maven-plugin

<pluginManagement> 
     <plugins> 
      <!--This plugin's configuration is used to store Eclipse m2e settings 
       only. It has no influence on the Maven build itself. --> 
      <plugin> 
       <groupId>org.eclipse.m2e</groupId> 
       <artifactId>lifecycle-mapping</artifactId> 
       <version>1.0.0</version> 
       <configuration> 
        <lifecycleMappingMetadata> 
         <pluginExecutions> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId>net.alchim31.maven</groupId> 
            <artifactId>yuicompressor-maven-plugin</artifactId> 
            <versionRange>[1.0,)</versionRange> 
            <goals> 
             <goal>compress</goal> 
             <goal>jslint</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <ignore /> 
           </action> 
          </pluginExecution> 
         </pluginExecutions> 
        </lifecycleMappingMetadata> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 

3) In case you don't prefer polluting your pom file with this metadata, you can store this in an external XML file(option 3). Below is a sample mapping file which instructs m2e to ignore the jslint and compress goals of the yuicompressor-maven-plugin

<?xml version="1.0" encoding="UTF-8"?> 
<lifecycleMappingMetadata> 
    <pluginExecutions> 
     <pluginExecution> 
      <pluginExecutionFilter> 
       <groupId>net.alchim31.maven</groupId> 
       <artifactId>yuicompressor-maven-plugin</artifactId> 
       <versionRange>[1.0,)</versionRange> 
       <goals> 
        <goal>compress</goal> 
        <goal>jslint</goal> 
       </goals> 
      </pluginExecutionFilter> 
      <action> 
       <ignore/> 
      </action> 
     </pluginExecution> 
    </pluginExecutions> 
</lifecycleMappingMetadata> 

4) In case you don't like any of these 3 options, you can use an m2e connector(extension) for the maven plugin.The connector will in turn provide the metadata to m2e. You can see an example of the metadata information within a connector at this link . You might have noticed that the metadata refers to a configurator. This simply means that m2e will delegate the responsibility to that particular java class supplied by the extension author.The configurator can configure the project(like say add additional source folders etc) and decide whether to execute the actual maven plugin during an incremental build(if not properly managed within the configurator, it can lead to endless project builds)

Refer these links for an example of the configuratior(link1 , link2). So in case the plugin is something which can be managed via an external connector then you can install it. m2e maintains a list of such connectors contributed by other developers.This is known as the discovery catalog. m2e will prompt you to install a connector if you don't already have any lifecycle mapping metadata for the execution through any of the options(1-6) and the discovery catalog has got some extension which can manage the execution.

The below image shows how m2e prompts you to install the connector for the build-helper-maven-plugin. install connector suggested from the discovery catalog .

5)m2e encourages the plugin authors to support incremental build and supply lifecycle mapping within the maven-plugin itself.This would mean that users won't have to use any additional lifecycle mappings or connectors.Some plugin authors have already implemented this

6) By default m2e holds the lifecycle mapping metadata for most of the commonly used plugins like the maven-compiler-plugin and many others.

Now back to the question :You can probably just provide an ignore life cycle mapping in 1, 2 or 3 for that specific goal which is creating trouble for you.

+0

Я уже видел этот ответ, но я не сужу, что мне нужно сделать, чтобы исправить эту проблему? – john

+0

Я обновляю свой ответ с помощью этой информации. – Fabien