Deploying project JAR to artifactory programmatically

梦想与她 提交于 2019-12-25 03:58:12

问题


Deploy programatically created KIE-Drools-Artifact to Maven repository has come closest to what I'm trying to do.

I have artifactory set up as a remote repository for a project, and what I want to do is deploy snapshot releases to the libs-shapshot-local repository from one project so that they can be accessed via others.

As for my code, I'm working with Drools/java and I am able to create a JAR file and deploy it to the local .m2 repository from inside the program(thanks to the above question), I'm able to upload the JAR to artifactory via the maven command line, but for some reason I've been unable to get the JAR into artifactory via the java code.

I've looked through this site and a couple others, but can't quite seem to find the right reference material. I've used the following for reference: How to deploy JAR to Maven remote repository http://blog.chintoju.com/2012/12/deploy-to-artifactory-remote-repository-using-maven.html

Thanks in advance!


回答1:


Artifactory has an open source Java client you can use for this.
Here is a simple deployment example:

InputStream inputStream = new FileInputStream("myfile.ext");
Artifactory artifactory = ArtifactoryClient.create("http://localhost:8081/artifactory", "username", "password");
File deployed = artifactory.repository("libs-shapshot-local").upload("path/to/deploy", inputStream).doUpload();

You can download the latest version of the client from Bintray or simply point your Maven build at http://jcenter.bintray.com



来源:https://stackoverflow.com/questions/24517243/deploying-project-jar-to-artifactory-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!