发布jar包到自己设立的Maven Repository

使用Artifactiry为自己的开发团队设立了repository镜像。有时需要把本地的一些第三方的jar包发布到服务器,使用maven-deploy-plugin的deploy:deploy-file目标可以完成这个任务。

比如,要发布jta的jar包jta-1.0.1B.jar

$ mvn deploy:deploy-file -DgroupId=javax.transaction \
   -DartifactId=jta \
   -Dversion=1.0.1B \
   -Dpackaging=jar \
   -Dfile=~/.m2/repository/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar \
   -DrepositoryId=central \
   -Durl=http://host.of.your.repository[:port]/artifactory/ibiblio@repo

说明:

  • repositoryId在工程的pom文件里设置
  • url由Artifactiry的配置决定,注意不能使用virtual repository的地址
  • 如果远程repository需要身份验证,用户名和密码需要在maven的settings.xml里设置

参考:

  • http://maven.apache.org/guides/mini/guide-deploying-3rd-party-jars.html
  • http://www.jfrog.org/sites/artifactory/latest/import.html

2 thoughts on “发布jar包到自己设立的Maven Repository

  1. 请问这里的用户名和密码是指在artifactory中设置的用户名和密码吗?如果不是的话,那应当怎么设置?谢谢!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.
For more help see http://daringfireball.net/projects/markdown/syntax

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>