在Eclipse中使用Maven构建多个项目
我在本地环境中有7个项目,其中一些相互依赖.我已经按照特定的顺序构建了它们,以准备开发环境.我必须执行更新依赖性,然后为此按特定顺序在每个项目上进行全新安装.
有什么捷径可以代替手动步骤吗?如何创建运行配置(或以其他任何方式)以按一定顺序构建所有项目?
I have 7 projects in my local environment and some of them depend on each other. I have built them in a particular sequence to prepare my development environment. I have to do update dependency and then maven clean install on each project in a particular sequence for this.
Is there any shortcut to do this instead of the manual steps? How do I create a run configuration ( or any other way) to build all projects in some sequence?
-Sunil
If these 7 projects are parts of a whole project then what you need is a Maven multi-module project. When you are done setting it up the directory structure will look like:
project-root
|
+-- project-1
|
+-- project-2
.
.
|
+-- project-7
另一方面,如果这些仅仅是7个其他独立项目,则您将在每个项目中建立与其他相关项目的依赖关系.
On the other hand if these are just 7 otherwise independent project you would set up dependencies in each project on other related projects.
请注意,在后一种情况下,独立项目只是因为您构建 project-x
并不意味着 project-y
将接受更改.在构建 project-x
时,必须执行 mvn install
以确保将其推送到本地Maven存储库.然后,您必须在 project-y
上运行 mvn软件包
(或 mvn install
).
Be aware that in the latter case of independent projects, just because you build project-x
it doesn't mean that project-y
will pick up changes. When you build project-x
you have to do mvn install
to ensure that it gets pushed to your local Maven repository. Then you have to run mvn package
(or mvn install
) on project-y
.
由于您使用的是Eclipse,因此我强烈建议您安装 M2Eclipse插件.它将大大简化您的Eclipse配置与POM的更改保持同步的步伐.
Since you are using Eclipse I would highly recommend installing the M2Eclipse plugin. It will greatly simplify keeping your Eclipse configuration in lock-step with any POM changes.