2011-10-26 1558 views
44

意圖得到M2E 1.0正常工作,我不得不指定生命週期的映射:擺脫POM的沒有發現org.eclipse.m2e警告:生命週期映射

<pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.eclipse.m2e</groupId> 
       <artifactId>lifecycle-mapping</artifactId> 
       <version>1.0.0</version> 
       <configuration> 
        <lifecycleMappingMetadata> 
         <pluginExecutions> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId>org.bsc.maven</groupId> 
            <artifactId>maven-processor-plugin</artifactId> 
            <versionRange>[2.0.2,)</versionRange> 
            <goals> 
             <goal>process</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <execute /> 
           </action> 
          </pluginExecution> 
         </pluginExecutions>       
        </lifecycleMappingMetadata> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 

但後來我得到這樣的警告:

[WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available 
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 

,如果我跑例如mvn clean install findbugs:findbugs一些特定的maven任務(如果我只運行mvn clean install那麼有沒有這樣的郵件)

我知道,問題是,這個POM不存在,因爲它只被定義爲保存映射信息。 (m2e lifecycle-mapping not found

無論如何,我想保持我的構建乾淨,沒有任何警告,所以我該如何擺脫這個特定的? (我CI服務器檢查沒有警告。

我使用Maven 3.0.2,並試圖Maven的3.0.3過,但相同的結果。

+0

您正在運行哪個Maven版本? – khmarbaise

+0

@khmarbaise:這是maven 3.0.2 – Ralph

+0

你可以發佈這個項目的完整POM ...因爲我認爲你有你的pom中的某個地方的依賴...順便說一句:你有沒有試圖用Maven 3.0運行這個。 3? – khmarbaise

回答

47

我的團隊解決了這個問題,通過在成型包裝相關的配置:

<profile> 
    <id>only-eclipse</id> 
    <activation> 
    <property> 
     <name>m2e.version</name> 
    </property> 
    </activation> 
    <build> 
    <pluginManagement> 
     <plugins> 
     <plugin> 
      <groupId>org.eclipse.m2e</groupId> 
      <artifactId>lifecycle-mapping</artifactId> 
      <version>1.0.0</version> 
      <configuration> 
      ... 
      </configuration> 
     </plugin> 
     </plugins> 
    </pluginManagement> 
    </build> 
</profile> 
+0

是否需要在eclipse中激活該配置文件? – Ralph

+0

@Ralph Nope,屬性激活工作,因爲只有Eclipse定義了m2e.version屬性 - 它不是由vanilla Maven或其他IDE激活的。它確實假設你正在使用M2E Eclipse集成(File> Import> Existing Maven Project),而不是舊的eclipse:eclipse目標。 – ctrueden

+0

@ctrueden謝謝你 - 我參考。它來自https://bugs.eclipse.org/bugs/show_bug.cgi?id=367870 – vorburger

8

此解決方案現在已被棄用,我建議使用@ctrueden的「配置文件」解決方案,這是公認的答案!

雖然不是最乾淨的解決方案,你可以使用一個倉庫管理器時,在你的公司或者是你自己的,在此期間,你可以這樣做: - 結帳https://github.com/mfriedenhagen/dummy-lifecycle-mapping-plugin。 - 當您自己運行時運行mvn install - 運行mvn deploy -DaltDeploymentRepository=REPO_ID::default::YOUR_THIRDPARTY_REPO_URL當您擁有像Nexus或Artifactory這樣的存儲庫管理器時。 - 同樣見https://github.com/mfriedenhagen/dummy-lifecycle-mapping-plugin/blob/master/README.creole

問候 米爾科

+0

它是一個黑客,但它是目前我能想到的最好的解決方案 – Ralph

+0

@Ralph我編輯了答案並用一些項目對它進行了測試。 –

+0

根據你的棄用警告,我改變他接受國旗,對不起。 – Ralph

1

現在有現在更好的解決方案(在Eclipse中只有錯誤消息)。

CTR + 1上的錯誤插件執行未包括生命週期配置:org.codehaus.mojo:buildnumber-行家-插件:1.1:創建時間戳(執行:默認創建時間戳,相:驗證),然後選擇此選項:

enter image description here

這適用於org.eclipse.m2e.editor.xml_1.2.0.20120903-1050.jar插件(也許還早)

+0

但是,當您將其存儲在設置中時,其他人會再次看到此設置。因此,對於部署到第三方存儲庫的公司來說可能更加可行:-)。 –

+0

當我們在CI框中看到錯誤時,這將不起作用 – Blundell

+3

您命名的快速修復將生命週期映射配置添加到pom。這將*引起問題所指出的問題,而不是解決問題。 – Kissaki

11

這是一個known bugWONTFIX分辨率。建議的解決方案在我看來是最簡單的:

mvn archetype:generate -DgroupId=org.eclipse.m2e -DartifactId=lifecycle-mapping \ 
-Dversion=1.0.0 -DarchetypeArtifactId=maven-archetype-mojo 

install這個項目。

+1

這很好。我將distributionManagement-> repository標記添加到我們本地nexus repo的pom中,並進行了mvn部署,以便爲我的團隊修復它。 –

1

m2eclipse的1.7.0推出了替代方案,即一個XML處理指令。

在最初的例子,您只需將「註釋」的maven-processor-pluginprocess目標每<execution>

<?m2e execute?> 

release notes的語法和其他選項的更多細節。