我试图使用mvn help:effective-pom命令在示例应用程序上生成有效的pom. http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-pom.html 在这篇文章中它说有效的pom是超级pom和应用程序pom之间的合并.
但是,当我看到我的有效pom时,它包含的元素不包含在超级pom或有效pom中.
是否有其他因素决定什么进入有效的pom.
以下是超级pom和应用程序pom,这两个pom都没有mavne-jar-plugin或maven-compiler-plugin,但在我的有效pom中,我可以在构建部分看到这些插件.那么它是如何被添加的呢?
提前感谢您澄清此问题的任何帮助
超级POM
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law …Run Code Online (Sandbox Code Playgroud) 使用 Maven 3.0.4。
我的任务是为我们的组织提供公司母公司 POM。我的团队将为开发人员在使用此 POM 时遇到的问题或问题提供支持。通常,他们会将构建日志附加到支持请求中。因此,我希望我的公司 POM 能够通过任何构建将公司父级的版本回显到控制台。我正在为此使用 antrun 插件。
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>echo-build-environment</id>
<phase>validate</phase>
<goals><goal>run</goal></goals>
<configuration>
<target>
<echo level="info" message="Maven ${maven.version}" taskname="Version" />
<echo level="info" message="Corporate POMs ${want.the.version.here}" taskname="Version" />
....
</target>
Run Code Online (Sandbox Code Playgroud)
诀窍是,我不知道在公司母公司和构建中使用的 POM 之间可能会有多少 POM 继承的“级别”。我们可以有这样的继承结构:
corporate-parent
team-parent
application-parent
child-module
Run Code Online (Sandbox Code Playgroud)
或者像这样简单:
corporate-parent
a-simple-library
Run Code Online (Sandbox Code Playgroud)
我无法回应,${project.version}因为这将是当前(子)项目的版本。我无法使用,${project.parent.version}因为我不知道可能有多少级继承。我尝试定义一个<corporate.pom.version>属性,硬编码到公司 POM 版本,但是当我发布我的公司 POM 时,发布插件不知道更新该属性(这是有道理的,它不是依赖版本,它只是一个属性,发布版本不知道更新它)。
理想情况下,我希望能够直接通过属性获取特定 POM 的版本,例如${some.groupId.corporate-parent.version}. 这样的东西存在吗?
如果没有,在发布期间有没有办法使用releaseVersion正在发布的项目的更新 POM 属性?
我可以恢复到在每次发布之前手动编辑属性的蛮力方式。我的队友不会欣赏这种方法。
我希望我不必编写自定义插件来做一些乍一看似乎并不困难的事情。
那些日子我很难学习Maven,这似乎比学习我所知道的所有4-5种编程语言更难.然而,第一步已经完成,我成功地在Eclipse中使用m2eclipse插件构建了第一个基于Jersey的Java REST服务项目.当我尝试这样做时,我添加了一堆全局存储库,其中大多数都是不相关或不正确的,不知何故,我将它们全部添加到'Effective POM'而不是项目POM,因此全局存在大量垃圾存储库.现在的问题是:
如何编辑/管理"有效POM"以删除这些存储库?我尝试使用内置的POM编辑器执行此操作,但它将其显示为只读,还尝试通过"Maven存储库"选项卡删除它们,但根本没有这样的选项.
也许有一些方法可以手动编辑它,全局POM在文件系统中的位置?
在"有效POM"我可以看到两个标签中添加复制库<repository>和<pluginRepository>.这些标签有什么区别?如果我手动删除它们,我应该同时删除它们吗?