如何在 Maven 中使用 POM 作为依赖项? [英] How to use POMs as a dependency in Maven?

查看:55
本文介绍了如何在 Maven 中使用 POM 作为依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将 pom 类型依赖添加到我的 POM 并获取其所有模块?

Is there a way to add a pom type dependency to my POM and get all its modules?

JavaMail 就是一个很好的例子.Maven Central Repo 有一个父 POM,名为:com.sun.mail:all:1.5.0 包含以下模块:mail、mailapi、mailapijar、smtp、imap、gimap、pop3 和 dsn.

JavaMail is a good example. Maven Central Repo has a parent POM called: com.sun.mail:all:1.5.0 with modules: mail, mailapi, mailapijar, smtp, imap, gimap, pop3, and dsn.

然而,all"人工制品只有一个文件:pom.xml 有没有办法将这个all"人工制品作为依赖项添加到我的 POM 并获取其所有模块?我 90% 肯定这不是在 Maven 中使用依赖项的正确方法,但我想听听堆栈专家的意见.

However, the "all" artefact only has a single file: pom.xml Is there a way to add this "all" artefact as a dependency to my POM and get all its modules? I am 90% sure this is not the right way to use dependencies in Maven, but I want to hear it from an expert on The Stack.

想法:

  • ...pom
  • ...pomimport<;/dependencyManagement>

相关:Netbeans:pom 类型的 maven 依赖

推荐答案

简短的回答:您不能在 Maven 中执行此操作.

The short answer: You cannot do this in Maven.

其他答案仅使所有"POM 成为依赖项.不能解决问题.另一个答案尝试导入所有"POM 的依赖项.我不需要依赖;我需要所有"POM 的(子)模块.同样,并没有解决问题.

The other answers make only the "all" POM a dependency. Does not solve the issue. Another answer tries to import the dependencies of the "all" POM. I don't need the dependencies; I need the (child) modules of the "all" POM. Again, does not solve the issue.

旁注:我错误地使用了 JavaMail 库.我只需要添加一个依赖项:com.sun.mail:javax.mail:1.5.0

Side note: I was using the JavaMail library incorrectly. I only needed to add one dependency: com.sun.mail:javax.mail:1.5.0

这篇关于如何在 Maven 中使用 POM 作为依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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