Public Repo Creation
Create a Sonatype Repo which can be used for the deployment of the project jars. For this, follow Step 2 and 3 from here.
After u create the JIRA ticket, the guys responsible will get back to you with all the relevant details including the repositories to which you can deploy
Now we have a snapshot and release repo ready. So let’s ready our project for deployment.
Changes in your POM file
- Make sure you have all these elements in your POM file
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Make sure that you append -SNAPSHOT to
<version>
. Don’t worry, when your project jar is being deployed to the release repo, the “-SNAPSHOT” string will be removed.Add the following xml snippets in your POM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
- Add the distribution info like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
- Add the Sonatype parent info:
1 2 3 4 5 |
|
- Create a file
settings.xml
inside your local Maven repository folder (which is usually~/.m2/
), and add the following xml snippet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
The username and password refers to the one you used for creating the jira account earlier.
Using Public key to sign artifacts
You can sign your project jars using pgp signatures by following the instructions here
Make sure to upload your key to the public keyserver as mentioned in the link above.
The
maven-gpg-plugin
plugin above will help to sign all your project jars with a pgp signature.
Upload to Repository
Before you proceed, make sure to push all the changes made locally to your SCM. This is a very important step.
Create a public SSH key in github, if you don’t have one. If not created, you will face the following error while uploading
1
|
|
- To upload your project to the snapshot repository simply run
1
|
|
- To upload your project for staging before the actual release, run the commands below
1 2 3 4 5 |
|
- If your project was prepared successfully, use the following command to upload the jars to the staging repository.
1
|
|
If everything ran well, you have now successfully deployed your project artifacts to the sonatype staging repository.
Promote staged project to Maven repo
- Login to Sonatype Repository browser
- Follow the instructions given here
- Before you release your jars into Maven Central, make sure to download and test them locally.
- Do not release your artifacts without ensuring that they work as expected
Once your staged release has been promoted and synced to the Central Repo, do not forget to close the JIRA ticket you created in the beginning.
That’s it. You’re done ! Go and chillout :)