mvn:deploy在整合或者发布环境下执行,将最终版本的包拷贝到远程的repository,使得其他的开发者或者工程可以共享。
一 配置settings.xml
因为nexus是需要登陆操作,当然可以通过配置免登陆,这是后话。
在settings.xml的<servers></servers>
<server>
<id>thirdparty</id>
<username>admin</username>
<password>admin123</password>
</server>
当然如果你要上传包去其他仓库,可依照此例,如
<server>
<id>central</id>
<username>admin</username>
<password>admin123</password>
</server>
如果进行deploy时返回Return code is: 401错误,则需要进行用户验证或者你已经验证的信息有误。
二 cmd输入命令
mvn deploy:deploy-file -DgroupId=com.xy.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar -Dfile=E:\ojdbc14.jar -Durl=http://localhost:9090/nexus-2.2-01/content/repositories/thirdparty/ -DrepositoryId=thirdparty
DgroupId和DartifactId构成了该jar包在pom.xml的坐标,项目就是依靠这两个属性定位。自己起名字也行。
Dfile表示需要上传的jar包的绝对路径。
Durl 私服上仓库的位置,打开nexus——>repositories菜单,可以看到该路径。
url中也可以指定用户名、密码。格式:http://<username>:<password>@localhost:9200/nexus-2.2-01/content/repositories/thirdparty/
DrepositoryId 对应maven配置文件setting.xml中server标签的id
如果url中没有指定用户名、密码,需要指定repositoryId
Dversion表示版本信息,怎样得到一个jar包准确的版本呢?
解压该包,会发现一个叫MANIFEST.MF的文件,这个文件就有描述该包的版本信息。
比如Manifest-Version: 1.0可以知道该包的版本了。
上传成功后,在nexus界面点击3rd party仓库可以看到这包。
三、mvn deploy命令参数说明
mvn deploy:help -Ddetail=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.7:help (default-cli) @ standalone-pom ---
[INFO] org.apache.maven.plugins:maven-deploy-plugin:2.7
Maven Deploy Plugin
Uploads the project artifacts to the internal remote repository.
This plugin has 3 goals:
deploy:deploy
Deploys an artifact to remote repository.
Available parameters:
altDeploymentRepository
Specifies an alternative repository to which the project artifacts should
be deployed ( other than those specified in <distributionManagement> ).
Format: id::layout::url
Expression: ${altDeploymentRepository}
retryFailedDeploymentCount (Default: 1)
Parameter used to control how many times a failed deployment will be
retried before giving up and failing. If a value outside the range 1-10 is
specified it will be pulled to the nearest value within the range 1-10.
Expression: ${retryFailedDeploymentCount}
skip (Default: false)
Set this to 'true' to bypass artifact deploy
Expression: ${maven.deploy.skip}
updateReleaseInfo (Default: false)
Parameter used to update the metadata to make the artifact as release.
Expression: ${updateReleaseInfo}
deploy:deploy-file
Installs the artifact in the remote repository.
Available parameters:
artifactId
ArtifactId of the artifact to be deployed. Retrieved from POM file if
specified.
Expression: ${artifactId}
classifier
Add classifier to the artifact
Expression: ${classifier}
classifiers
A comma separated list of classifiers for each of the extra side artifacts
to deploy. If there is a mis-match in the number of entries in files or
types, then an error will be raised.
Expression: ${classifiers}
description
Description passed to a generated POM file (in case of generatePom=true)
Expression: ${generatePom.description}
file
File to be deployed.
Required: Yes
Expression: ${file}
files
A comma separated list of files for each of the extra side artifacts to
deploy. If there is a mis-match in the number of entries in types or
classifiers, then an error will be raised.
Expression: ${files}
generatePom (Default: true)
Upload a POM for this artifact. Will generate a default POM if none is
supplied with the pomFile argument.
Expression: ${generatePom}
groupId
GroupId of the artifact to be deployed. Retrieved from POM file if
specified.
Expression: ${groupId}
javadoc
The bundled API docs for the artifact.
Expression: ${javadoc}
packaging
Type of the artifact to be deployed. Retrieved from the <packaging>
element of the POM file if a POM file specified. Defaults to the file
extension if it is not specified via command line or POM.
Maven uses two terms to refer to this datum: the <packaging> element for
the entire POM, and the <type> element in a dependency specification.
Expression: ${packaging}
pomFile
Location of an existing POM file to be deployed alongside the main
artifact, given by the ${file} parameter.
Expression: ${pomFile}
repositoryId (Default: remote-repository)
Server Id to map on the <id> under <server> section of settings.xml In
most cases, this parameter will be required for authentication.
Required: Yes
Expression: ${repositoryId}
repositoryLayout (Default: default)
The type of remote repository layout to deploy to. Try legacy for a Maven
1.x-style repository layout.
Expression: ${repositoryLayout}
retryFailedDeploymentCount (Default: 1)
Parameter used to control how many times a failed deployment will be
retried before giving up and failing. If a value outside the range 1-10 is
specified it will be pulled to the nearest value within the range 1-10.
Expression: ${retryFailedDeploymentCount}
sources
The bundled sources for the artifact.
Expression: ${sources}
types
A comma separated list of types for each of the extra side artifacts to
deploy. If there is a mis-match in the number of entries in files or
classifiers, then an error will be raised.
Expression: ${types}
uniqueVersion (Default: true)
Whether to deploy snapshots with a unique version or not.
Expression: ${uniqueVersion}
updateReleaseInfo (Default: false)
Parameter used to update the metadata to make the artifact as release.
Expression: ${updateReleaseInfo}
url
URL where the artifact will be deployed.
ie ( file:///C:/m2-repo or scp://host.com/path/to/repo )
Required: Yes
Expression: ${url}
version
Version of the artifact to be deployed. Retrieved from POM file if
specified.
Expression: ${version}
deploy:help
Display help information on maven-deploy-plugin.
Call
mvn deploy:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
Available parameters:
detail (Default: false)
If true, display all settable properties for each goal.
Expression: ${detail}
goal
The name of the goal for which to show help. If unspecified, all goals
will be displayed.
Expression: ${goal}
indentSize (Default: 2)
The number of spaces per indentation level, should be positive.
Expression: ${indentSize}
lineLength (Default: 80)
The maximum length of a display line, should be positive.
Expression: ${lineLength}
相关推荐
本主题将深入探讨如何将自定义的jar包上传到远程仓库,以供其他项目或团队成员引用。首先,我们需要理解几个关键概念: 1. **本地仓库**: Maven在本地磁盘上创建的一个默认目录,用于存储下载的依赖和构建的项目...
使用`mvn deploy`命令,项目会被发布到远程仓库。配置`<repository>`或`<snapshotRepository>`元素指定目标远程仓库。 5. **maven-deploy-plugin**: Maven的部署插件负责将项目发布到远程仓库。我们可以自定义其...
脚本原理:读取指定路径下的所有pom后缀的文件,摘取里面的groupid,version,artifactId内容,拼装成mvn deploy:deploy-file语句,可以直接在linux下执行,或者在win环境通过复制里面的命令在cmd执行。
将本地jar包上传到maven仓库,刷新仓库后即可使用
5. **自定义仓库**:在`settings.xml`中可以配置额外的远程仓库地址,对于一些私有或者公司内部的库,可以上传到自定义仓库。 6. **清理与更新**:`mvn clean`命令可以清除目标目录的编译产物,`mvn dependency:...
在cmd中mvn更新和打包
标题中的“mvn+svn+linux打包”涉及的是在Linux环境下使用Maven(mvn)和Subversion(svn)工具进行软件项目的构建和版本控制。这里我们将深入探讨这三个关键概念及其在软件开发过程中的作用。 1. Maven: Maven是...
批量上传 jar包到maven 私服 自动生成dependency ,不用到私服搜索 核心代码用python编写
例如,`mvn install`命令会编译源代码,运行测试,打包项目,并将结果安装到本地仓库。其中,`mvn dependency:get`命令可以用来单独下载一个特定的依赖。 在批处理文件中使用`mvn`命令下载`pom.xml`中的jar包,通常...
命令`mvn deploy`会将文件上传到指定的远程仓库。 5. 自动化脚本: `Version&Deploy.bat`很可能是一个批处理文件,用于组合上述Maven命令。它可能包括如下步骤: - 更新版本号 - 执行清理、编译、测试和打包 - ...
手动部署文件到远程仓库:`mvn deploy:deploy-file` 当需要手动部署文件到远程仓库时,可以使用该命令。例如: ``` mvn deploy:deploy-file -DgroupId=...
2、使用方法1:在本地仓库repository文件夹中右键,打开Git Bahs Here命令(本地需要下载Git工具),然后用文本打开本工具,复制其中的命令“find xxx” 粘贴到Git Bahs Here中,回车执行即可清理无效文件。...
遍历文件夹及子文件夹下得pom文件,自动清理、编译、安装。适合批量编译多个maven工程
若需部署到远程仓库,则可以使用`mvn deploy`。 ** Maven生命周期与构建阶段 ** Maven的生命周期包括清理(clean)、编译(compile)、测试(test)、打包(package)、验证(verify)、集成测试(integration-...
本地mvn仓库清理无用jar包
- 运行`mvn dependency:resolve`或`mvn install`命令,Maven会自动从私服仓库中拉取所需的jar包,并将其安装到本地仓库中供项目使用。 综上所述,通过上述步骤,你可以轻松地在阿里云环境中搭建一个maven私服,并...
一键删除maven本地仓库中下载错误的jar包资源(以lastUpdated结尾的文档)
下载之后再maven的bin目录下使用mvn命令:mvn install:install-file -Dfile=F:\apache-maven-3.5.3\mylib\olap4j-0.9.7.309-JS-3.jar -DgroupId=org.olap4j -DartifactId=olap4j-0.9.7.309-JS-3 -Dversion=0.9.7.309...
Maven 的强大之处在于其插件机制,`mvn jetty:run` 可以直接将项目部署到 Jetty 服务器运行,`mvn deploy:deploy-file` 用于上传自定义的 JAR 文件到远程仓库。 总之,理解并熟练使用这些 Maven 命令行,将有助于你...