Maven 将 jar 包安装到本地仓库。
想通过 Maven 导入 jar 包,而 Maven 中央仓库(Mavenrepository)和本地仓库都没有,就会报错。
这时我们可以将 jar 包安装到本地 Maven 仓库。
mvn install:install-file -DgroupId=com.arcsoft.face -DartifactId=arcsoft-sdk-face -Dversion=2.2.0.1 -Dpackaging=jar -Dfile=arcsoft-sdk-face-2.2.0.1.jar
- mvn install:install-file 的参数。
https://maven.apache.org/plugins/maven-install-plugin/usage.html
mvn install:install-file -Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml] \
[-Dsources=src.jar] \
[-Djavadoc=apidocs.jar] \
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=sources] \
[-DgeneratePom=true] \
[-DcreateChecksum=true]
看看官网介绍。
Apache Maven Install Plugin
The Install Plugin is used during the install phase to add artifact(s) to the local repository. The Install Plugin uses the information in the POM (groupId, artifactId, version) to determine the proper location for the artifact within the local repository.
The local repository is the local cache where all artifacts needed for the build are stored. By default, it is located within the user’s home directory (~/.m2/repository) but the location can be configured in ~/.m2/settings.xml using the element.
- Goals Overview
The Install Plugin has 3 goals:
- install:install
is used to automatically install the project’s main artifact (the JAR, WAR or EAR), its POM and any attached artifacts (sources, javadoc, etc) produced by a particular project.- install:install-file
is mostly used to install an externally created artifact into the local repository, along with its POM. In that case the project information can be taken from an optionally specified pomFile, but can also be given using command line parameters.- install:help
displays help information on maven-install-plugin.
D:\lyfGeek。download。\ArcSoft_ArcFace_Java_Windows_x64_V2.2\libs>E:\lyfGeek\apache-maven-3.6.3\bin\mvn install:help
[WARNING]
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Unrecognised tag: 'id' (position: START_TAG seen ...</profile>\r\n -->\r\n\r\n <id>... @222:9) @ E:\lyfGeek\apache-maven-3.6.3\bin\..\conf\settings.xml, line 222, column 9
[WARNING]
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:help (default-cli) @ standalone-pom ---
[INFO] Maven Install Plugin 2.4
Copies the project artifacts to the user's local repository.
This plugin has 3 goals:
install:help
Display help information on maven-install-plugin.
Call mvn install:help -Ddetail=true -Dgoal=<goal-name> to display parameter
details.
install:install
Installs the project's main artifact, and any other artifacts attached by
other plugins in the lifecycle, to the local repository.
install:install-file
Installs a file in the local repository.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.948 s
[INFO] Finished at: 2020-09-24T16:21:25+08:00
[INFO] ------------------------------------------------------------------------