安装次要工件

有时您需要在本地存储库中安装主要工件后安装辅助工件。要安装辅助工件,您需要使用分类器参数对辅助工件进行分类。

让我们假设您要安装旧工件的源代码,例如 commons-logging-1.0.3。中央存储库仅具有该版本的主要工件和-javadoc工件。将源打包到本地磁盘上的 JAR 文件中,然后运行以下命令:

mvn org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file  -Dfile=path-to-commons-logging-sources.jar \
                                                                              -DgroupId=commons-logging \
                                                                              -DartifactId=commons-logging \ 
                                                                              -Dversion=1.0.3 \
                                                                              -Dpackaging=jar \
                                                                              -Dclassifier=sources

注意:通过使用目标的完全限定路径,可以确保您使用的是 maven-install-plugin 的首选版本。使用mvn install:install-file时,其版本取决于 pom 中的规范或 Apache Maven 的版本。