maven-compiler-plugin 不会从 2.0.2.SP1 升级到 2.3.2
我是 Maven 新手,已经学习 Maven 一周了,有 5 年使用 Ant 的经验,所以我能够轻松上手。我已经通读了 maven.apache.org 上的所有文档两次——阅读了数百页。我使用几种不同的 Maven 原型创建了几个测试应用程序,以便在阅读文档时更好地理解。现在,我正在设置我的新项目,并且更精细的点正在发挥作用...
我想我知道为什么 maven-compiler-plugin 在运行时不会升级到最新版本 2.3.2,
mvn versions:use-latest-release
但我需要知道是否有解决方法,或者我是否应该担心。首先,这是我的 pom.xml 的片段:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
如您所见,我指定版本 2.3.2。考虑到 Maven 可能存在问题,不知道它需要更新存储库中的文件,我运行了 mvn versions:use-latest-releases 我注意到 jar 文件被下载到 ~/.m2/repository/org/apache/ maven/plugins/maven-compiler-plugin/ 即
ll ~/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.3.2
total 60
-rw-rw-r--. 1 pgarner pgarner 29176 Oct 7 21:29 maven-compiler-plugin-2.3.2.jar
-rw-rw-r--. 1 pgarner pgarner 335 Oct 7 21:29 maven-compiler-plugin-2.3.2.jar.lastUpdated
-rw-rw-r--. 1 pgarner pgarner 40 Oct 7 21:29 maven-compiler-plugin-2.3.2.jar.sha1
-rw-rw-r--. 1 pgarner pgarner 7329 Oct 7 21:29 maven-compiler-plugin-2.3.2.pom
-rw-rw-r--. 1 pgarner pgarner 335 Oct 7 21:29 maven-compiler-plugin-2.3.2.pom.lastUpdated
-rw-rw-r--. 1 pgarner pgarner 40 Oct 7 21:29 maven-compiler-plugin-2.3.2.pom.sha1
-rw-rw-r--. 1 pgarner pgarner 208 Oct 7 21:29 _maven.repositories
但是当我运行以下命令时,很明显 maven-compiler-plugin 版本仍为 2.0.2.SP1:
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin
/usr/java/jdk1.7.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building RichFaces 4 Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.1.1:describe (default-cli) @ Patrac ---
[INFO] org.apache.maven.plugins:maven-compiler-plugin:2.0.2.SP1
Name: Maven Compiler Plugin
Description: Maven Plugins
Group Id: org.apache.maven.plugins
Artifact Id: maven-compiler-plugin
Version: 2.0.2.SP1
Goal Prefix: compiler
注意到我确实使用了richfaces-archetype-simpleapp 原型来生成这个项目,并且我需要将 JBoss 存储库添加到项目中,我的下一个想法是 RichFaces 中可能存在某些内容阻止项目使用最新的编译器,我采取了查看
~/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata-jboss-public-repository-group.xml
果然在那里,我想,我发现了问题:
<latest>2.4-SNAPSHOT</latest>
<release>2.0.2.SP1</release>
<versions>
<version>0.1-stub-SNAPSHOT</version>
<version>2.0.2.SP1</version>
<version>2.3.2-SNAPSHOT</version>
<version>2.4-SNAPSHOT</version>
</versions>
那么,这是否意味着 RichFaces 不能与 maven-compiler-plugin 版本 2.3.2 一起使用?
我想使用最新版本的 maven-compiler-plugin 开始这个新项目。我想远离使用快照并坚持使用版本。我的直觉告诉我,将版本 2.3.2 的条目添加到上述 XML 文件(即 2.3.2)中是完全危险的。我说得对吗?或者这只是 JBoss-Maven 存储库没有包含所有版本的 maven-compiler-plugin 的完整集合的问题?
我有什么选择?我应该满足于使用 v.2.0.2.SP1 吗?或者有没有办法要求 Maven 忽略 maven-metadata-jboss-public-repository-group.xml,或者可能要求 Maven 优先考虑 Maven 中央存储库而不是 JBoss 存储库?
I'm a Maven newbie, have been studying Maven for a week now, have 5 years experience using Ant, so I'm able to come up to speed without trouble. I have read through all documentation at maven.apache.org twice -- several hundred pages of reading. I have created several test apps using several different Maven archetypes to better my understanding as I've read through the documentation. Now, I'm setting up my new project and the finer points are coming into play...
I think I know why the maven-compiler-plugin won't upgrade to the latest release, 2.3.2, when I run
mvn versions:use-latest-release
but I need to know if there is a workaround, or if I should even be concerned. First, here's a snip of my pom.xml:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
As you can see I am specifying version 2.3.2. Thinking there might be a problem with Maven not knowing it needed to update its files in the repository, I ran mvn versions:use-latest-releases I noticed that the jar file was downloaded into ~/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/ i.e.
ll ~/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.3.2
total 60
-rw-rw-r--. 1 pgarner pgarner 29176 Oct 7 21:29 maven-compiler-plugin-2.3.2.jar
-rw-rw-r--. 1 pgarner pgarner 335 Oct 7 21:29 maven-compiler-plugin-2.3.2.jar.lastUpdated
-rw-rw-r--. 1 pgarner pgarner 40 Oct 7 21:29 maven-compiler-plugin-2.3.2.jar.sha1
-rw-rw-r--. 1 pgarner pgarner 7329 Oct 7 21:29 maven-compiler-plugin-2.3.2.pom
-rw-rw-r--. 1 pgarner pgarner 335 Oct 7 21:29 maven-compiler-plugin-2.3.2.pom.lastUpdated
-rw-rw-r--. 1 pgarner pgarner 40 Oct 7 21:29 maven-compiler-plugin-2.3.2.pom.sha1
-rw-rw-r--. 1 pgarner pgarner 208 Oct 7 21:29 _maven.repositories
But when I ran the following it was evident that the maven-compiler-plugin version remained as 2.0.2.SP1:
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin
/usr/java/jdk1.7.0
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building RichFaces 4 Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.1.1:describe (default-cli) @ Patrac ---
[INFO] org.apache.maven.plugins:maven-compiler-plugin:2.0.2.SP1
Name: Maven Compiler Plugin
Description: Maven Plugins
Group Id: org.apache.maven.plugins
Artifact Id: maven-compiler-plugin
Version: 2.0.2.SP1
Goal Prefix: compiler
Noting that I did use the richfaces-archetype-simpleapp archetype to generate this project, and that I was required to add the JBoss repository to the project, my next thought was that there might have been something in RichFaces that prevented the project from using the latest compiler, I took a look at
~/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/maven-metadata-jboss-public-repository-group.xml
and sure enough there, I think, I found the problem:
<latest>2.4-SNAPSHOT</latest>
<release>2.0.2.SP1</release>
<versions>
<version>0.1-stub-SNAPSHOT</version>
<version>2.0.2.SP1</version>
<version>2.3.2-SNAPSHOT</version>
<version>2.4-SNAPSHOT</version>
</versions>
So, does this mean that RichFaces cannot be used with maven-compiler-plugin version 2.3.2?
I would like to get started on this new project using the latest version of maven-compiler-plugin. I would like to stay away from using snapshots and stick with releases. My instinct tells me that it would be completely dangerous to add an entry for version 2.3.2 to the above XML file i.e. 2.3.2. Am I correct? Or is this simply a matter of the JBoss-Maven repository not having a complete set of all the versions of the maven-compiler-plugin?
What are my options? Should I just be satisfied with using v. 2.0.2.SP1? Or is there a way to ask Maven to ignore maven-metadata-jboss-public-repository-group.xml, or perhaps ask Maven to give precedence to the Maven Central repository over the JBoss repository?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在这里已经了解了很多,所以我会尝试将其拆开并尽可能多地回答......
根据下面的代码片段运行时,看起来效果很好。我刚刚检查了编译插件页面,2.3.2 实际上是最新版本。
当您运行此命令时:
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin
我猜这是默认值。如果您在所述项目中运行/usr/java/jdk1.7.0
mvncompile
,它应该使用您指定的 2.3.2。不要管元数据文件,除非您是在自找麻烦或真正知道自己在做什么:)
我不认为该插件的 2.0.2.SP1 正在被使用。即使是这样,在我看来,使用插件的快照也没什么大不了的。使用依赖项快照绝对需要谨慎。
我确信有一些方法可以覆盖哪个存储库以什么顺序解析什么内容,但我不知道在这种情况下它会对您有多大帮助。
我希望这有帮助。
You've got quite a bit here, so I'll try and take it apart and answer as much as I can...
Based on your snippet below that, it looks like it worked fine. I just checked the compile plugin page and 2.3.2 is in fact the latest version.
When you run this:
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-compiler-plugin
I'm guessing that is a default. If you run/usr/java/jdk1.7.0
mvn compile
in said project, it should use 2.3.2 as you've specified.Leave the metadata files alone unless you are looking for trouble or really know what you are doing :)
I don't think 2.0.2.SP1 of the plugin is being used. Even if it was\is, using snapshots of plugins isn't too big of a deal IMO. Using snapshots of dependencies definitely needs caution.
I'm sure that there are ways to override which repository resolves what, and in what order, but I don't know how much it will help you in this instance.
I hope this helps.