2014-05-07 51 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时无法按预期方式使用附加工件)。

作为一般规则:不要对代码使用附加的工件(带分类器)。