gpt4 book ai didi

maven-2 - 如何在一个命令行中下载特定的 Maven 工件?

转载 作者:行者123 更新时间:2023-12-02 23:44:30 24 4
gpt4 key购买 nike

我可以通过 install:install-file 安装工件,但我怎样才能下载工件呢?

例如:

mvn download:download-file -DgroupId=.. -DartifactId=.. -Dversion=LATEST

最佳答案

您可以使用maven dependency plugin其中有一个不错的 dependency:get 自 2.1 版本以来的目标。不需要 pom,一切都在命令行上发生。

确保找到dependency:get目标,您需要明确告诉maven使用版本2.1,即您需要使用插件的完全限定名称,包括版本:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \
-DrepoUrl=url \
-Dartifact=groupId:artifactId:version

更新:使用旧版本的 Maven(2.1 之前),可以运行 dependency:get通常(不使用完全限定名称和版本)通过强制您的 Maven 副本使用插件的给定版本。

这可以按如下方式完成:

<强>1。在 <settings> 中添加以下行您的元素~/.m2/settings.xml文件:

<usePluginRegistry>true</usePluginRegistry>

<强>2。添加文件~/.m2/plugin-registry.xml包含以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<pluginRegistry xsi:schemaLocation="http://maven.apache.org/PLUGIN_REGISTRY/1.0.0 http://maven.apache.org/xsd/plugin-registry-1.0.0.xsd"
xmlns="http://maven.apache.org/PLUGIN_REGISTRY/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<useVersion>2.1</useVersion>
<rejectedVersions/>
</plugin>
</plugins>
</pluginRegistry>

但这似乎不再适用于 maven 2.1/2.2。实际上,根据Introduction to the Plugin Registryplugin-registry.xml 的特点已经重新设计(为了可移植性),并且插件注册表目前在 Maven 2 中处于半休眠状态。所以我认为我们现在必须使用长名称(当使用没有 pom 的插件时,这就是 dependency:get 背后的想法)。

关于maven-2 - 如何在一个命令行中下载特定的 Maven 工件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1895492/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com