Currently I have a Maven2 project that builds a JAR when you run:
mvn clean package
I need to now tweak the pom.xml
to publish this JAR (myapp.jar
) to an Artifactory server running at:
http://myartifactory/artifactory/simple/myorg/myapp/0.1
I tried adding a <repositories>
element to my pom.xml
but nothing is being published with this config:
<repositories>
<repository>
<id>myartifactory</id>
<url>http://myartifactory/artifactory/simple/</url>
</repository>
</repositories>
Any ideas as to how I could get publishing to work? For simplicity's sake, pretend that this Artifactory repo is authenticated to accept publishes/writes from a user with a username=foo
and password=bar
.
Go to the artifact browser, select the repository you want to upload to, and hit the Set Me Up button for instructions. You can upload a file using Artifactory UI. Go to the artifact browser, select the repository you want to upload to, and hit the Upload button for instructions.
Once you have created your Maven repository, go to Application | Artifactory | Artifacts, select your Maven repository and click Set Me Up. In the Set Me Up dialog, click Generate Maven Settings. You can now specify the repositories you want to configure for Maven.
Upload to the Artifactory repository manually The easiest way, and the least DevOps-friendly way, to upload a JAR to an Artifactory repository is to simply log in to the administrative console, select a target folder and drag and drop the JAR onto the deployment screen.
You have two options (please note that the later is the recommended one):
Add DistributionManagement
part to your pom and server
part to your settings.xml
Distribution Management
snippet and paste it in your pom.xml
:
server
tag from Maven Settings
panel:
This one you paste in your settings.xml
. Don't forget to replace the ${server-id} with the real server id (the one you have in Distribution Management now).mvn deploy
and enjoy.Working with Maven Artifactory Plugin:
<plugin>
part as described in the wiki to your pom.xml
. It includes both the target repository and the credentials (please use external credentials source, like environment variables or system properties).mvn deploy
and enjoy not only the deployment to Artifactory, but also additional features as described below.Additional features of Artifactory Maven Plugin (on top of regular Maven deployment):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With