How to lock maven plugin version
How can I lock the version of a Maven plugin I want to use?
I have the PMD plugin configured like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<outputDirectory>target/pmd</outputDirectory>
<targetDirectory>target/</targetDirectory>
<aggregate>true</aggregate>
<targetJdk>1.6</targetJdk>
<rulesets>
<ruleset>rulesets/basic.xml</ruleset>
<ruleset>rulesets/codesize.xml</ruleset>
<ruleset>rulesets/coupling.xml</ruleset>
<ruleset>rulesets/design.xml</ruleset>
<ruleset>rulesets/imports.xml</ruleset>
<ruleset>rulesets/logging-java.xml</ruleset>
<ruleset>rulesets/optimizations.xml</ruleset>
开发者_开发知识库 <ruleset>rulesets/strings.xml</ruleset>
<ruleset>rulesets/unusedcode.xml</ruleset>
</rulesets>
</configuration>
</plugin>
Last night, my nightly build failed and I can no longer run any pmd goals because it is trying to find version 2.6-SNAPSHOT of that plugin. Why is it even trying to find 2.6-SNAPSHOT if I have a version tag that says 2.5? Also, 2.6-SNAPSHOT is not in central - why does my maven client think it exists?
Maven version: 2.0.9
Java version: 1.6.0_17 OS name: "linux" version: "2.6.24-24-generic" arch: "i386" Family: "unix"Edit:
I upgraded to maven 2.2.1 and observed the same issue as before. I was able to get the project to build by removing 2.6-SNAPSHOT from the metadata in my repository (.m2/repository/org/apache/maven/plugins/maven-pmd-plugin/maven-metadata-central.xml). I also set the latestVersion tag to 2.5. This is obviously not the solution, because I'd have to either deploy my own plugin or change the cached version on all clients.
Standard procedure in such cases: delete the corresponding plugin folder in your local repo:
.m2/repository/org/apache/maven/plugins/maven-pmd-plugin/
This helps in most cases.
If not, you are probably getting bad data from a repository. If you are using a nexus, rebuild the index.
精彩评论