44

デフォルトのクイックスタート Maven の例を生成し、 と入力すると、常に最新バージョンmvn checkstyle:checkstyleを使用しようとします。SNAPSHOTおそらく私のNexusサーバーでは間違っていますが、Maven 2のコマンドラインでプラグインのバージョンを設定するにはどうすればよい2.5です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

mvn checkstyle:2.5:checkstyle残念ながらそうではありません。

確かに でビルドの依存関係を設定すればpom.xml動作しますが、コマンド ラインがどのように機能するかを確認したいと思います。

4

4 に答える 4

78

ローカル リポジトリにインストールされているプラ​​グインの最新バージョンを実行したくない場合は、バージョン番号を設定する必要があります。そのためには、次の形式で完全に修飾された目標を指定する必要があります。

mvn groupID:artifactID:version:goal

だからあなたの場合:

mvn org.apache.maven.plugins:maven-checkstyle-plugin:2.5:checkstyle
于 2010-05-20T10:17:34.127 に答える
1

新しいバージョンの maven(3.3.9) での私の経験は少し異なります。オフライン モードで Maven を実行していない場合は、ローカル リポジトリにあるものに関係なく、常にリモート リポジトリに移動します。新しいバージョン (maven-metadata.xml に基づく) が見つかった場合は、そのバージョンをダウンロードして使用します。さらに、複数のリポジトリを同時にスキャンします。

[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 は複数のメタデータ ファイルを比較して最新バージョンのアーティファクトを選択する方法を知っているようです。Maven は、私が見たものに基づいて、Aether を使用して依存関係を解決しますresolver-status.properties

    #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=
于 2018-02-19T21:35:53.273 に答える