简体   繁体   English

为平面多模块maven项目配置SCM,以便eclipse可以立即检出所有内容

[英]Configure SCM for flat multi-module maven project so that eclipse can checkout everything at once

I've been playing a lot with this and can't find a proper way to do it. 我一直在玩很多,但找不到合适的方法。 This is my setup: 这是我的设置:

/parent
  pom.xml
    <modules>
      <module>../module-1</module>
      ...
      <module>../module-n</module>
    </modules>
    <scm><connection>https://repo/trunk</connection>...</scm>
/module-1
  pom.xml
...
/module-n
  pom.xml

I was expecting eclipse to checkout all sub modules projects when I checkout the parent. 当我结账时,我期待eclipse检查所有子模块项目。 Is that possible in a flat project hierarchy? 这在平面项目层次结构中是否可行?

The give structure implies that your module-1 is on the same level as parent which does not make sense neither in Eclipse nor in Maven. 给定结构意味着你的module-1与父级处于同一级别,这在Eclipse和Maven中都没有意义。 The best is to structure the project like the following: 最好是按如下方式构建项目:

 +-- parent (pom.xml)
        +-- module-1 (pom.xml)
        +-- module-2 (pom.xml)

With such a structure you can simple checkout the parent and get everything you need to work with. 有了这样的结构,您可以简单地检查父项并获得您需要使用的所有内容。 apart from that it will make your pom file in particular the modules part simpler which can done like this: 除此之外,它将使您的pom文件特别是模块部分更简单,可以这样做:

<modules>
  <module>module-1</module>
  ..
  <module>module-n</module>
</modules>

and your childs simply use the parent like this: 而你的孩子只需使用这样的父母:

   <parent>
     <groupId>..</groupId>
     <artifactId>..</artifactId>
     <version>...</version>
   </parent>
  • If your sub-modules do not live independently of their aggregating project, it is probably better to move to a hierarchical structure, as suggested in @khmarbaise's answer. 如果您的子模块不是独立于其聚合项目而生活,那么最好转移到层次结构,如@ khmarbaise的答案所示。
  • If yours are really independent projects consider handling them as libraries and keep them separate from the aggregator project; 如果您的实际上是独立项目,请考虑将它们作为库处理,并将它们与聚合器项目分开; this would mean releasing them separately and use your aggregator just to assemble them for release as a war or a zip file. 这将意味着单独发布它们并使用您的聚合器来组装它们以作为战争或zip文件发布。
  • If you're somewhat stuck in the middle, because you'd like to be able to use your sub-modules separately, but you're developing all of them at the same time and you're using Subversion for version control you might hook your sub-modules to your aggregator by means of Subversion's externals mechanism. 如果你有点卡在中间,因为你希望能够单独使用你的子模块,但你同时开发所有这些子模块并且你使用Subversion进行版本控制你可能会挂钩您的子模块通过Subversion的外部机制到您的聚合器。 This requires a little more work than having a single, multi-module repository, but it's rather convenient for working with Eclipse. 这需要比单个多模块存储库更多的工作,但是使用Eclipse非常方便。 The downside is the fact that as far as I know the Maven Release plugin cannot deal with this configuration. 缺点是,据我所知,Maven Release插件无法处理此配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM