Maven - 聚合的“全部”或“父母”项目? [英] Maven - 'all' or 'parent' project for aggregation?

查看:185
本文介绍了Maven - 聚合的“全部”或“父母”项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于教育目的,我已经建立了一个类似的项目布局(为了更好地适应日食而持平):

For educational purposes I have set up a project layout like so (flat in order to suite eclipse better):

-product
 |
 |-parent
 |-core
 |-opt
 |-all

父包含一个包含core,opt和all的聚合项目。 Core实现了应用程序的强制部分。 Opt是可选部分。所有这些都应该将core与opt结合起来,并将这两个模块列为依赖项。

Parent contains an aggregate project with core, opt and all. Core implements the mandatory part of the application. Opt is an optional part. All is supposed to combine core with opt, and has these two modules listed as dependencies.

我现在正在尝试制作以下工件:

I am now trying to make the following artifacts:


  1. product-core.jar

  2. product-core-src.jar

  3. 产品-core-with-dependencies.jar

  4. product-opt.jar

  5. product-opt-src.jar

  6. product-opt-with-dependencies.jar

  7. product-all.jar

  8. product-all-src.jar

  9. product-all-with-dependencies.jar

  1. product-core.jar
  2. product-core-src.jar
  3. product-core-with-dependencies.jar
  4. product-opt.jar
  5. product-opt-src.jar
  6. product-opt-with-dependencies.jar
  7. product-all.jar
  8. product-all-src.jar
  9. product-all-with-dependencies.jar

大多数产品都非常简单。我确实有一些聚合工件的问题。我已经设法在'all'模块中使用自定义程序集描述符生成product-all-src.jar,该模块下载所有非传递deps的源代码,这样可以正常工作。这项技术还允许我制作产品 - 所有 - 依赖.jar。

Most of them are fairly straightforward to produce. I do have some problem with the aggregating artifacts though. I have managed to make the product-all-src.jar with a custom assembly descriptor in the 'all' module which downloads the sources for all non-transitive deps, and this works fine. This technique also allows me to make the product-all-with-dependencies.jar.

我最近发现你可以在源代码中使用source:aggregate目标插件来聚合整个聚合项目的源。对于javadoc插件也是如此,它也通过父项目的使用进行聚合。

I however recently found out that you can use the source:aggregate goal in the source plugin to aggregate sources of the entire aggregate project. This is also true for the javadoc plugin, which also aggregates through the usage of the parent project.

所以我在'all'模块方法和放弃'之间徘徊'所有'模块,只需使用'父'模块进行所有聚合。在'父'中产生一些聚合工件并且在'all'中产生其他产品感觉不干净。有没有办法在父项目中制作'product-all'jar,或者在'all'项目中聚合javadoc?或者我应该保留两者?

So I am torn between my 'all' module approach and ditching the 'all' module and just use the 'parent' module for all aggregation. It feels unclean to have some aggregate artifacts produced in 'parent', and others produced in 'all'. Is there a way of making an 'product-all' jar in the parent project, or to aggregate javadoc in the 'all' project? Or should I just keep both?

谢谢

推荐答案

扁平的树木不再经常使用。这是几年前完成的,用于处理Eclipse如何处理项目以及缺乏良好的Maven和Eclipse集成。如果你使用m2eclipse将Maven项目导入Eclipse,你就不会遇到maven典型嵌套树的任何问题。

Flattened trees are not often used anymore. This was done several years ago to deal with how Eclipse handled projects and the lack of good Maven and Eclipse integration. If you use m2eclipse to import Maven projects into Eclipse, you won't have any problems with a maven-typical nested tree.

至于什么是一个很好的例子如何构建Maven构建? Maven项目源本身。它包含您想要的所有部分,包括最终的汇编打包捆绑包。

As far as what is a good example of how to structure a Maven build? The Maven project source itself. It has all the pieces you desire, including the final assembly that packages up the bundles.

典型的嵌套结构有一个自上而下的层次结构,其中父进程正在对其下面的模块和子进行聚合从父级继承值。虽然这些可以并且有时是分开的,但这不是常态。

The typical nested structure has a top down hierarchy where the parent is doing the aggregation of the modules below it, and the children are inheriting values from the parent. Although these can and sometimes are separate, this is not the norm.

这篇关于Maven - 聚合的“全部”或“父母”项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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