0

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!

Community
  • 1
  • 1
user3795030
  • 3
  • 1
  • 3

1 Answers1

3

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

Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
  • That definitely helped, thank you. Unfortunately, I'm now getting "Request /libs-shapshot-local/validation-1.0.0-SNAPSHOT.jar should be a repo request and does not match any repo key" in my Artifactory log along with a series of errors in the console when I try to run the program. It keeps getting a 403 Forbidden error: 14:49:38.024 [main] DEBUG org.apache.http.headers - << HTTP/1.1 403 Forbidden 14:49:38.024 [main] DEBUG org.apache.http.headers - << Server: Artifactory/3.2.2 Thoughts? – user3795030 Jul 02 '14 at 18:58
  • 1
    You will need to post your code and other relevant information to troubleshoot it. Preferably in a new question. In addition, you should take a look at the Artifactory client unit tests, they contain a lot of examples on how to use it. – Dror Bereznitsky Jul 02 '14 at 19:06
  • Found it: small typo snapshot -> shapshot. All works, but I think I need more coffee. Thank you! – user3795030 Jul 02 '14 at 19:34