首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Maven2的命令行中设置插件的版本

在Maven2的命令行中设置插件的版本
EN

Stack Overflow用户
提问于 2010-05-20 12:42:33
回答 4查看 17.9K关注 0票数 44

我生成默认的快速入门Maven示例,并输入mvn checkstyle:checkstyle,它总是尝试使用最新的SNAPSHOT版本。也许在我的Nexus服务器上是错误的,但是我如何在Maven2的命令行上设置插件的版本,比如用2.5代替2.6-SNAPSHOT来设置checkstyle

代码语言:javascript
复制
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

我猜它可能是mvn checkstyle:2.5:checkstyle,但不幸的是它不是。

当然,如果我在pom.xml中设置了构建依赖,它将会工作,但我想看看命令行是如何工作的。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-05-20 18:17:34

如果您不想运行安装在本地存储库中的插件的最新版本,则需要设置版本号。为此,您需要以以下形式指定一个完全限定的目标:

代码语言:javascript
复制
mvn groupID:artifactID:version:goal

所以在你的例子中:

代码语言:javascript
复制
mvn org.apache.maven.plugins:maven-checkstyle-plugin:2.5:checkstyle
票数 78
EN

Stack Overflow用户

发布于 2018-02-20 05:35:53

我使用较新版本的maven(3.3.9)的体验略有不同。如果我不是在脱机模式下运行maven,那么无论我在本地存储库中有什么,它都将总是转到远程repo。如果它找到一个较新的版本(基于maven-metadata.xml),它将下载并使用该版本。更重要的是,它将同时扫描多个repo:

代码语言:javascript
复制
[INFO] ------------------------------------------------------------------------
[DEBUG] Resolving plugin version for com.phoenixnap.oss:springmvc-raml-plugin
[DEBUG] Could not find metadata com.phoenixnap.oss:springmvc-raml-plugin/maven-metadata.xml in local (/home/yuranos/.m2/repository)
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.spring.io/libs-milestone
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.spring.io/milestone
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.maven.apache.org/maven2
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://repo.spring.io/snapshot
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.spring.io/libs-milestone
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.spring.io/milestone
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.maven.apache.org/maven2
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://repo.spring.io/snapshot
Downloading: https://repo.spring.io/libs-milestone/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml
Downloading: https://repo.spring.io/snapshot/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml
Downloading: https://repo.spring.io/milestone/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml
[DEBUG] Writing tracking file /home/yuranos/.m2/repository/com/phoenixnap/oss/springmvc-raml-plugin/resolver-status.properties
[DEBUG] Writing tracking file /home/yuranos/.m2/repository/com/phoenixnap/oss/springmvc-raml-plugin/resolver-status.properties
Downloaded: https://repo.maven.apache.org/maven2/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml (2 KB at 1.0 KB/sec)
[DEBUG] Writing tracking file /home/yuranos/.m2/repository/com/phoenixnap/oss/springmvc-raml-plugin/resolver-status.properties
Downloaded: https://repo.spring.io/libs-milestone/com/phoenixnap/oss/springmvc-raml-plugin/maven-metadata.xml (2 KB at 0.9 KB/sec)
[DEBUG] Writing tracking file /home/yuranos/.m2/repository/com/phoenixnap/oss/springmvc-raml-plugin/resolver-status.properties
[DEBUG] Could not find metadata com.phoenixnap.oss:springmvc-raml-plugin/maven-metadata.xml in spring-snapshots (https://repo.spring.io/snapshot)
[DEBUG] Could not find metadata com.phoenixnap.oss:springmvc-raml-plugin/maven-metadata.xml in spring-milestones-libs (https://repo.spring.io/milestone)

更重要的是,maven似乎知道如何比较几个元数据文件并选择工件的最新版本。根据我在resolver-status.properties中看到的,Maven使用以太来解决依赖关系:

代码语言:javascript
复制
    #NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Mon Feb 19 23:41:24 EET 2018
maven-metadata-spring-milestones.xml.lastUpdated=1519076484366
maven-metadata-spring-snapshots.xml.error=
maven-metadata-central.xml.lastUpdated=1519076484205
maven-metadata-spring-snapshots.xml.lastUpdated=1519076484107
maven-metadata-spring-milestones-libs.xml.lastUpdated=1519076484105
maven-metadata-spring-milestones-libs.xml.error=
票数 1
EN

Stack Overflow用户

发布于 2018-10-05 10:51:10

代码语言:javascript
复制
mvn org.apache.maven.plugins:maven-site-plugin:3.7.1:site
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2871054

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档