如何在Idea IDE中正确使用m2ecipse和maven?
目前,我发现我们团队对Maven的使用效率非常低。所以我有这个问题。
我们有一个由 300-500 个模块组成的大项目,这些模块由 Maven 3 组织,我将其分为 10 个子项目,因此每个子项目都有一个根 pom.xml
。假设它们是project1、project2、..projectN。我主要工作的project3
由30个模块组成,然后它们被project4
和project5
所依赖。
project3:
module3-1 SNAPSHOT
module3-2 SNAPSHOT
module3-3 SNAPSHOT
module3-4 SNAPSHOT
module3-5 SNAPSHOT
module3-6 RELEASE
...
module3-30 RELEASE
在project3中,发布了一些不那么频繁更改的模块,而一些(module3-1..3-5)更改非常频繁,所以我在这里使用SNAPSHOT版本。
我们运行了一个 Archiva 服务器来管理所有工件,包括发布版本和快照版本。
现在的问题是,当我更改 project3
中的某些内容时,通常我想部署整个子项目:
[my-ubuntu] ~/project3/$ mvn clean; mvn deploy
...
EVERYTHING SUCCEED
[my-ubuntu] ~/project3/$
对于我的期望是,所有快照版本都应该自动下载并保存在我的项目中。在其他人的机器上更新。
在命令行中,它按预期工作:
[john's ubuntu] ~/project4/$ mvn package
...
download http://archiva-server/snapshots/project3/...-SNAPSHOT... [SUCCEEDED]
...
EVERYTHING SUCCEED
[john's ubuntu] ~/project4/$
但是,Gin 讨厌命令行,所以他使用 M2eclipse,但 M2eclipse 不会自动更新快照。我尝试过:
TRY 1:
Disable dependency resolution
Enable dependency resolution
(This take maybe 30 minutes, and make eclipse hang, so I don't like. And it seems not work most of time, not download the latest snapshots sometimes)
TRY 2:
Update all dependnecies
Refresh projects
(This take about maybe 5 minutes, but not work some time, not download the latest snapshots sometimes)
TRY 3:
Delete all projects from eclipse workspace
Re-import all projects
(This take maybe 10 minutes, and most "clean" way, though not very fast but okay)
(But not download the latest snapshots sometimes)
TRY 4:
[gin's ubuntu] ~/project4/$ cd ~/.m2/repository/../project3
[gin's ubuntu] ~/.m2/repository/../project3 $ find -name 'resolve-*' -delete
Refresh eclipse projects
(This take about maybe 5 minutes? Well I haven't time it, though.)
(This is the best resolution in my experience, it downloads all snapshots everytime, so it's the final-resolution, well sounds like problem-killer.)
所以,根据我的个人经验,删除本地存储库中的 resolve-*
文件似乎是最好的解决方案,但感觉不太好。
与命令行调用 mvn
相比,所有 IDE 都很糟糕。也许我没有以正确的方式管理 Maven?
我想知道在 Eclipse/Idea IDE 中正确使用 Maven 的最佳工作流程。
Currently, I found that it's very inefficient use of Maven in our team. So I have this question.
We have a large project consists of 300-500 modules which are organized by Maven 3, I have divided it into 10 sub-projects, so each sub-project have a root pom.xml
. Say they are project1, project2, .. projectN. I mainly work on project3
consists of 30 modules, they are then depended by project4
and project5
.
project3:
module3-1 SNAPSHOT
module3-2 SNAPSHOT
module3-3 SNAPSHOT
module3-4 SNAPSHOT
module3-5 SNAPSHOT
module3-6 RELEASE
...
module3-30 RELEASE
In project3, some not so often changes modules are released, and some (module3-1..3-5) are changed very frequently, so I use SNAPSHOT versions here.
We have run an Archiva server to manage all the artifacts, include both released and snapshots version.
Now the problem is, when I changed something in my project3
, generally I would like to deploy the whole sub-project:
[my-ubuntu] ~/project3/$ mvn clean; mvn deploy
...
EVERYTHING SUCCEED
[my-ubuntu] ~/project3/$
For what I expect is, all the snapshot versions should be automatically downloaded & updated in other people's machines.
In command line, it's worked as expected:
[john's ubuntu] ~/project4/$ mvn package
...
download http://archiva-server/snapshots/project3/...-SNAPSHOT... [SUCCEEDED]
...
EVERYTHING SUCCEED
[john's ubuntu] ~/project4/$
However, Gin hate command line, so he use M2eclipse, but M2eclipse won't automaticlly update the snapshots. I have tried:
TRY 1:
Disable dependency resolution
Enable dependency resolution
(This take maybe 30 minutes, and make eclipse hang, so I don't like. And it seems not work most of time, not download the latest snapshots sometimes)
TRY 2:
Update all dependnecies
Refresh projects
(This take about maybe 5 minutes, but not work some time, not download the latest snapshots sometimes)
TRY 3:
Delete all projects from eclipse workspace
Re-import all projects
(This take maybe 10 minutes, and most "clean" way, though not very fast but okay)
(But not download the latest snapshots sometimes)
TRY 4:
[gin's ubuntu] ~/project4/$ cd ~/.m2/repository/../project3
[gin's ubuntu] ~/.m2/repository/../project3 $ find -name 'resolve-*' -delete
Refresh eclipse projects
(This take about maybe 5 minutes? Well I haven't time it, though.)
(This is the best resolution in my experience, it downloads all snapshots everytime, so it's the final-resolution, well sounds like problem-killer.)
So, I my personal experience, to delete resolve-*
files in local repository seems the best resolution, but it's just not feel good.
Compared with command-line invoke mvn
, all IDE sucks.. Well maybe I didn't manage Maven in a correct way?
I'd like to know the best workflows to use Maven correctly in Eclipse/Idea stuff IDEs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您应该考虑项目的组织以及它们之间的关系。也许您应该使用多模块构建来更好地处理某些情况。
此外,您必须更改存储库的配置才能直接下载快照版本。更改settings.xml,特别是更新策略。
First You should think about the organization of your projects and their relationship to each other. May be you should about Multimodule builds to handle some of the situations in a better way.
Furthmore you have to change the configuration of the repositories to download the SNAPSHOT versions directly. Change the settings.xml in particular the update policy.