BND is a nice build tool, but in some cases it makes actually trivial things, seem impossible or at least not really obvious. Doing RELEASE and SNAPSHOT Builds is one of these things. Thus, here is a quick guide on how this can be done.
By default OSGi uses Semantic Versions like 220.127.116.1191126120000. The last part is called the qualifier and is usually a timestamp. Maven versions look close to OSGi versions. SNAPSHOT builds are marked as 1.0.0-SNAPSHOT and Maven will replace the SNAPSHOT with a timestamp qualifier for you. BND offers a similar Mechanism, given that each Project will get a Version that ends with .SNAPSHOT or -SNAPSHOT.
For your build.bnd
# We need an indicator, if we want to do a release or snapshot build. This macro looks for the Environment variable release.marker.
# If set the release.bnd will be included. If not the snapshot.bnd will be included.
# We need a Maven repository to deploy to. In this example it is a Nexus. NOTE: From time to time there is a Problem, when bnd needs to follow redirects from http to https on deployment.
# Thus always use https Urls, if you have HTTPS.
# The group ID to use
# instructs bnd to create and package a pom.xml
# define what repository should be used for the release. This can be coma separated list, if you have more then one
#We have to substitude the -SNAPSHOT with an empty String for releases or anything else
# instructs bnd to create the SNAPSHOT Versions for the pom.xml
Well, that's about it. If you want to build and deploy a snapshot, you have to use the release task:
if you want to build and deploy a release use the release task with our release marker property:
gradlew release -Drelease.marker=true
If you need to provide credentials for your maven repository, have a look at the bnd documentation for the issue here<