2014-05-07 52 views
0

我有一場包含java代碼的戰爭 - 並且需要讓其他代碼依賴於戰爭中包含的代碼。 我已閱讀其他有關使用maven-war-plugin的Maven WAR依賴 - 與eclipse構建衝突

<plugin> 
    <artifactId>maven-war-plugin</artifactId> 
    <version>2.4</version> 
    <configuration> 
     <attachClasses>true</attachClasses> 
    </configuration> 
</plugin> 

這工作正常。 我打造的原創戰爭和新的jar

search-classes.jar 
search.war 

該項目可以以兩種方式(1)在命令行中執行mvn(2)在Eclipse編譯爲一個標準的項目(不是Maven項目) - 這是我的公司怎麼做的!

因此,我正在使用eclipse編譯:在mvn命令行中使用eclipse,但是這使得原始項目現在依賴於eclipse .classpath文件中的自身。

這是該項目的搜索戰.classpath文件現在包含每一個Maven構建之後的行

<classpathentry kind="src" path="/search-war"/> 

我需要手動編輯這個(在Eclipse)。 有什麼辦法解決這個問題嗎?

Solution: 

There is a bug in the eclipse plugin. 
But it only shows up under specific conditions... 
The war was being renamed using the build/fileName tags. 
When i disabled this - the problem disappeared - and all is fine. 
(I just renamed the war in a post-build shell script instead). 
+1

貴公司正在遵循幾乎所有人都認爲效率非常低,成本高且容易出錯的自定義流程。唯一沒有這種感覺的人也做錯了。使用maven,遵循它的過程,並且蓬勃發展,然後向你的程序員和領導者證明這種善意,並希望他們能夠學習和跟隨你的領導。 –

回答

1

不是沒有拆分項目,即創建代碼一個單獨的模塊(其中只創建一個jar文件),把它作爲你的戰爭的依賴,以及需要的任何其他項目。

它更清潔,使用eclipse:eclipse以及m2e工作,並且在多模塊構建中沒有任何潛在問題(例如,僅在運行mvn compile時無法按預期方式使用附加工件)。

作爲一般規則:不要對代碼使用附加的工件(帶分類器)。