I'm a Maven newbie, have been studying M开发者_如何学JAVAaven 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?
You've got quite a bit here, so I'll try and take it apart and answer as much as I can...
I think I know why the maven-compiler-plugin won't upgrade to the latest release, 2.3.2, when I run
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
/usr/java/jdk1.7.0
I'm guessing that is a default. If you run mvn compile
in said project, it should use 2.3.2 as you've specified.
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?
Leave the metadata files alone unless you are looking for trouble or really know what you are doing :)
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?
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.
精彩评论