具有父pom和svn布局的多模块maven项目 [英] multi module maven project with parent pom and svn layout

查看:122
本文介绍了具有父pom和svn布局的多模块maven项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用Maven构建的大约16个项目被部署到组成门户"之类的同一应用服务器上.我建立了一个父pom来处理常见的依赖关系和插件配置.目前,我的SVN结构看起来与此类似:

I currently have about 16 projects that I build with maven that get deployed to the same application server that make up something like a "portal". I have built a parent pom to handle common dependencies and plugin configurations. Currently, my SVN structure looks similar to this:

portal_root
    +project1
        +tags
        +branches
        +trunk
    +project2
        .
        .
        .
    +projectn
    pom.xml

各个项目分别独立部署.也就是说,project1不依赖于project2,每个项目都可以修改和部署,而无需修改其他任何内容.

The individual projects are each separately deployed. That is, project1 doesn't have a dependency on project2 and each can be modified and deployed without having to modify anything else.

这带来了SVN的问题,好像另一个开发人员想要检出整个门户"根目录(以获取父pom)一样,他们也默认情况下会下拉所有标签和分支的副本!不太理想.

This presents a problem with SVN as if another developer wanted to check out the entire "portal" root (to also get the parent pom) they would also by default pull down copies of all the tags and branches! Not really ideal.

我唯一想到的另一件事就是使用类似这样的东西:

The only other thing I can think of is to use something like this:

 portal_root
     +tags
     +branches
     +trunk
         +project1
              +src
              pom.xml
         +project2
             .
             .
             .
         pom.xml

但是,现在所有项目更改都将在标签文件夹中进行跟踪.对我来说,这不是一个大问题,但是现在分支似乎变得很痛苦.

However, now all project changes will be tracked in the tags folder. This isn't a huge problem for me, but branching now seems to become a pain.

我目前还正在将Teamcity与此连接起来,这现在会更容易一些,因为我只需要观看一个目录(例如标签)即可捕获需要构建的所有内容.我还在将工件部署到企业Nessus存储库中.

I am also currently working on hooking up Teamcity into this as well which would be a bit easier now, since I would only have to watch a single directory (e.g. tags) to catch everything that needs to be built. I am also deploying artifacts to a enterprise Nessus repository.

我希望有人可以在这里给我一些建议,因为我一直无法在这里找到任何有关整个构建生命周期和最佳实践的不错的文档.

I'm hoping someone could give me some suggestions here as I have been unable to find any decent documentation that talks about the entire build lifecycle and best practices here.

我喜欢能够使用单个maven命令来构建和部署所有项目的想法.我还喜欢将所有常见的依赖项,存储库信息和插件信息放在一个地方.

I like the idea of being able to build and deploy all the projects with a single maven command. I also like having all the common dependencies, repository information and plugin information in one place.

推荐答案

您可以使用以下布局:

+parent-project
  pom.xml
+child-project-1
  pom.xml
+child-project-2
  pom.xml

在父项目pom中添加:

In parent project pom add:

<modules>
    <module>../child-project-1</module>
    <module>../child-project-2</module>
</modules>

在儿童项目pom中添加:

In children projects pom add:

<parent>
    <artifactId><!-- parent artifactId --></artifactId>
    <groupId><!-- parent groupdId --></groupId>
    <version><!-- parent version --></version>
    <relativePath>../parent-project</relativePath>
</parent>

儿童项目可以选择依赖.

Children Projects can optionally be dependent.

以下链接可能也有帮助:

Following links may also help:

  • http://maven.apache.org/guides/introduction/introduction-to-the-pom.html
  • Maven parent pom vs modules pom

这篇关于具有父pom和svn布局的多模块maven项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆