如何在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.
然而,只有全部有一个文件: pom.xml
有没有办法添加这个全部人工制品作为我的POM的依赖,并获得所有的模块?我有90%的确定这不是在Maven中使用依赖关系的正确方法,但是我想从Stack的专家那里听到。
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.
想法:
-
< dependencies>< dependency> ...< type> pom< / type>< / dependency> < / dependencies>
-
< dependencyManagement>< dependencies>< dependency> ...< type> pom< / type>< scope> import< / scope>< / dependency>< / dependencies>< / dependencyManagement>
<dependencies><dependency>...<type>pom</type></dependency></dependencies>
<dependencyManagement><dependencies><dependency>...<type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>
简短的回答:您不能在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