如何为多模块 Maven 项目配置 Jenkins

发布于 2024-12-12 12:24:56 字数 527 浏览 2 评论 0 原文

我有一个 Maven 多模块项目。结构如下:

-modulA         (Main project)
   - pom.xml
-parentModul    (Aggregator)
   - pom.xml
   - ModulB     (Integration Test Project)
       -pom.xml

包定义如下:

<project ...>
<modules>
    <module>../modulA</module>
    <module>ModulB</module>
</modules>


其中一个模块(ModulA)具有相同的层次结构级别,另一个位于父模块中。 我尝试在 Jenkins 中添加一个作业来自动构建所有内容。 (干净的包)..

我应该如何配置parentModul找到其他模块并构建项目的作业。?

I have a maven multi-modul project. The structure looks like:

-modulA         (Main project)
   - pom.xml
-parentModul    (Aggregator)
   - pom.xml
   - ModulB     (Integration Test Project)
       -pom.xml

Package definition is like:

<project ...>
<modules>
    <module>../modulA</module>
    <module>ModulB</module>
</modules>

One of the moduls (ModulA) has the same hierarchy level, The other is in the parent modul.
I try to add a job in Jenkins to build all automatically. (clean package)..

How should I configure the job that parentModul finds the other modules and build the project.??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赢得她心 2024-12-19 12:24:56

添加另一个聚合器。将 modulA 和parentModul 放在同一目录中并且比它们高一级,只需添加另一个pom,如下所示:

aggregator/
|- modulA/
|  |- pom.xml
|- parentModul/
|  |- modulB/
|  |  |- pom.xml
|  |- pom.xml
|- pom.xml

在 aggregator/pom.xml 中定义一个模块部分,如下所示:

<project ...>
    <modules>
        <module>modulA</module>
        <module>parentModul</module>
    </modules>
</project>

Add another aggregator. Place modulA and parentModul in the same directory and one level above them, simply add another pom like this:

aggregator/
|- modulA/
|  |- pom.xml
|- parentModul/
|  |- modulB/
|  |  |- pom.xml
|  |- pom.xml
|- pom.xml

In the aggregator/pom.xml define a modules section as follows:

<project ...>
    <modules>
        <module>modulA</module>
        <module>parentModul</module>
    </modules>
</project>
眼睛会笑 2024-12-19 12:24:56

一种解决方案是使用 SVNExternals 从疯狂的 SVN 结构中组装健全的 Maven 项目工作区,甚至跨不同的 svn 服务器。使用 svn external 并不是一个理想的解决方案,因为它会导致 maven 发布插件和 CI 的 SCM 轮询在某些配置中出现问题。他们告诉你:“你不应该使用 svn externals”,因为这会让生活变得更加困难。但是腿石膏和拐杖也是如此,但是当你断了腿(或 fubar 的 svn 结构)时,你真的不介意带来的不便。

有多种方法可以实现此目的,具体取决于您的 SVN 结构和所需的工作空间结构:

  1. svn co modulA
  2. cd modulA
  3. svn propedit svn:externals . < strong>注意:请注意行末尾的 (curdir) 点!
  4. 添加以下行:
    parentModul http://path.to.your.svn.location.of.parentModul
  5. svn ci -m“为父级添加外部”
  6. svn up

并且 svn 检索(并提交)您的代码到以下工作区结构

modulA/
|  |- pom.xml
parentModul/
|- modulB/
|  |- pom.xml
|- pom.xml
pom.xml

或者您可以向 SVN“工作区”添加一个新目录并添加新目录pom.xml 在那里,并通过 svn 外部获取您可能想要的所有模块到一个级别(或多个级别)。

One solution would be to use SVN Externals to assemble sane Maven project workspace from insane SVN structure even accross different svn servers. Using svn external is not an ideal solution as it will cause problems with maven release plugin and with CI's SCM polling in certain configuration. They tell you : "You should not use svn externals" as makes life more difficult. But so do leg cast and crutches but when you have broken leg (or svn structure that is fubar) you really do not mind the inconvenience.

There several ways of doing this, depending on your SVN structure and desired workspace structure:

  1. svn co modulA
  2. cd modulA
  3. svn propedit svn:externals . NB: Note the (curdir) dot at the end of line!
  4. add following line:
    parentModul http://path.to.your.svn.location.of.parentModul
  5. svn ci -m "added externals for parent"
  6. svn up

and the svn retrieves (and commits) you code to following workspace structure

modulA/
|  |- pom.xml
parentModul/
|- modulB/
|  |- pom.xml
|- pom.xml
pom.xml

Or you could add a new directory to SVN 'workplace' and add new pom.xml there and get all modules you could ever want via svn externals to one level (or to multiple levels).

一曲琵琶半遮面シ 2024-12-19 12:24:56

就我而言,不可能添加另一个父项目。 ModulA 已在 SVN 中独立于其他模块进行检查。

这表明您可能错误地将 moduleA 放入 部分。如果 moduleA 具有不同的生命周期,那么您应该将其作为依赖项包含在内。

In my case it is not possible to add another parent project. ModulA is already checked in SVN independently from the others.

This indicates that you're probably wrong in putting moduleA in the <modules> section. If moduleA has different life cycle, then you should include it as a dependency.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文