We release JBot using the maven-release plugin method. Before releasing, we have to setup gpg/gpg2 on our machine. This is required to sign our artifacts before releasing it to the Central Repository. We have to generate a key and distribute the public key to a key server. Follow the detailed PGP Signature Guide to learn more.
Follow the below steps to release JBot to OSSRH:
-
Make sure you have the
ossrh
profile in~/.m2/settings.xml
:<profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg2</gpg.executable> <gpg.passphrase>paste passphrase here</gpg.passphrase> </properties> </profile>
-
Have the
ossrh
server defined in~/.m2/settings.xml
:<servers> <server> <id>ossrh</id> <username>nexus jira username</username> <password>nexus jira password</password> </server> </servers>
-
We use maven multi-module for
jbot
withjbot-parent
being the parent andjbot
andjbot-example
the child modules. With multi-module, building/releasing the parent will build/release the parent as well as the child modules. To release:Do
$ cd JBot
and then$ mvn release:clean release:prepare
(you can use this option to see if all okay:-DdryRun=true
)Provide answers to the questions below:
What is the release version for "JBot Parent"? (me.ramswaroop.jbot:jbot-parent) 4.0.0: : What is SCM release tag or label for "JBot Parent"? (me.ramswaroop.jbot:jbot-parent) jbot-parent-4.0.0: : <use jbot-4.0.0 as tag> What is the new development version for "JBot Parent"? (me.ramswaroop.jbot:jbot-parent) 4.0.1-SNAPSHOT: :
-
Finally, run
$ mvn release:perform
to releasejbot-parent
(which also releasesjbot
andjbot-example
). -
Goto Sonatype, check the staging repository and if everything looks good, go ahead and close it. Refresh the table and then select the repo and click on "Release".
-
What is the structure of the parent pom and the child pom?
The parent pom will have the groupId, artifactId, version and packaging defined as well as it should have the modules tag defining all the child modules.
The child pom will have the parent tag stating the co-ordinates of the parent pom as well as the tags defining its own co-ordinates (unlike inheritance in maven).
See below for an example:
Parent pom Child pom <project> <groupId>me.ramswaroop.jbot</groupId> <artifactId>jbot-parent</artifactId> <version>4.0.2-SNAPSHOT</version> <packaging>pom</packaging> <modules> <module>jbot</module> <module>jbot-example</module> </modules> </project>
<project> <parent> <groupId>me.ramswaroop.jbot</groupId> <artifactId>jbot-parent</artifactId> <version>4.0.2-SNAPSHOT</version> </parent> <artifactId>jbot</artifactId> <version>4.0.2-SNAPSHOT</version> <packaging>jar</packaging> </project>
-
What is the benefit of multi-module in maven?
There are various advantages of multi-module, the most important being the ability to build/release all modules at once. You can build/release all modules by just building/releasing the parent module.
-
Can child modules have different versions than the parent?
I had different versions in parent and child modules but when I released jbot-parent
4.0.1
, the version ofjbot-example
also changed to4.0.1
. So, the answer is no. There may be some way but I am not aware of one. -
What about dependencies?
This is another advantage of multi-module. You can declare common dependencies across modules in the parent pom only but this isn't mandatory.