Edit the maven settings file (by default located at ~/.m2/settings.xml) and add following entries:
<settings>
<servers>
<server>
<id>ossrh</id>
<username>${nexus.user}</username>
<password>${nexus.password}</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</settings>
Make then the following actions.
1. Clean the project:
mvn clean
2. Prepare the release:
mvn -Dgpg.passphrase="yourpassphrase" -Dnexus.user="your_sonatype_username" -Dnexus.password="your_sonatype_password" release:prepare
3. Perform the release:
mvn -Dgpg.passphrase="yourpassphrase" -Dnexus.user="your_sonatype_username" -Dnexus.password="your_sonatype_password" release:perform
4. Update the Git project:
git push --tags
git push origin master
5. In case of problem during steps 1 to 4:
- 5.1: Undo the release:
git reset --hard HEAD~1
(You may have to do it a second time, depending upon when the error occurred.)
- 5.2: Delete the tag.
git tag -d tagName
git push origin :refs/tags/tagName