Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
194 views
in Technique[技术] by (71.8m points)

snapshot - Set plugin’s version on the command line in Maven 2

I generate default quickstart Maven example, and type mvn checkstyle:checkstyle, it always try to use the lastest SNAPSHOT version. Probably it is wrong in my Nexus server, but how can I set plugin's version on the command line in Maven 2, like 2.5 for checkstyle instead of 2.6-SNAPSHOT?

C:HelloWorld>mvn checkstyle:checkstyle
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'checkstyle'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

Project ID: org.apache.maven.plugins:maven-checkstyle-plugin

Reason: Error getting POM for 'org.apache.maven.plugins:maven-checkstyle-plugin' from  the repository: Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata.
  org.apache.maven.plugins:maven-checkstyle-plugin:pom:2.6-SNAPSHOT

from the specified remote repositories:
  nexus (http://localhost:9081/nexus/content/groups/public)

for project org.apache.maven.plugins:maven-checkstyle-plugin

I guess it could be mvn checkstyle:2.5:checkstyle, unfortunately it is not.

Surely if I set build dependance in pom.xml, it will work, but I want to see how command line can work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you don't want to run the latest version of a plugin installed in your local repository, you need to set the version number. And for that, you need to specify a fully-qualified goal in the form of:

mvn groupID:artifactID:version:goal

So in your case:

mvn org.apache.maven.plugins:maven-checkstyle-plugin:2.5:checkstyle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...