Savant Build Tool: Releasing

Brian Pontarelli
  • By Brian Pontarelli
  • Technology
  • December 22, 2014

One of the main concepts in software development is releasing. There is a distinct lack of good solutions for releasing software as most build tools drop the ball when it comes to releasing.

Savant release inversoftBefore we dive into how you configure Savant to perform a release, let's first talk about publishing artifacts. Savant defines a repository structure that is similar to the Maven repository structure. This structure uses the artifact group and project names as well as the project version to define the target directory and the artifact name, version and type form the file name.

Here's an example for the artifact com.mycompany:database-project:mysql:3.0.1:sql:

com/mycompany/database-project/3.0.1/mysql-3.0.1.sql

In order to configure your Savant project to publish artifacts, you must include a publications definition. This definition is broken into two groups. The first is the main group and the second is the test group. The main group are the primary publications of your project that are used at runtime. The test group are the publications of your project that are used at test time.

Here's how you define a publication for your project:

project(...) {
 publications {
  main {
   publication(name: "myproject", type: "jar", file: "build/jars/myproject.jar", sourceFile: "build/jars/myproject-src.jar")
  }
 }
}

This example defines a single publication named "myproject" of type JAR. The file and sourceFile define the artifact file and the source file for the publication. When this artifact is published, these files are uploaded to the Savant repository. Most IDEs have source JAR support, which can make debugging and coding much simpler. Therefore, we suggest you include source with all of your artifacts.

The next step is to configure the publishWorkflow that will be used to publish your artifacts. This is similar to the workflow definitions we covered in the dependency management blog post, but does not include the fetch and publish sections. Instead, it includes only the processes that are used to publish the artifacts. Here's an example:

project(...) {
 ...
 publishWorkflow {
  subversion(repository: "http://svn.example.com", username: "savant", password: "tooManySecrets")
 }
}

This publishWorkflow tells Savant that artifacts should be published into a Subversion repository under the username savant and the password provided. There is also an scp publish process you can use for publishing artifacts.

Let's look at a standard release process. Say your release process looks something like this:

  1. Check that your project doesn't depend on integration builds
  2. Ensure all changes are committed to source control
  3. Ensure everything is pushed to the remote source control
  4. Run all of the project's tests
  5. Create a release tag
  6. Push the tag to the remote source control
  7. Create the project artifacts
  8. Publish the artifacts to a repository

Savant makes that as simple as this:

release = loadPlugin("org.savantbuild.plugin:release-git:0.2.0")

target(name: "release", description: "Release the project") {
 release.release()
}

Using our Release Git plugin, you can release the artifacts from any project that is stored in a git repository, which will include creating the necessary tags.

Even if your release process is different, writing a custom release plugin is very simple and you can even reuse a lot of the code from our Release Git plugin.

We've covered a lot of ground in this post including how to define publications, publish workflows and also using the Savant Release Git plugin. You can learn more about releasing projects and writing custom plugins here:

http://github.com/inversoft/savant-core/wiki

This concludes our initial blog posts on Savant. We will publish new posts as we continue to expand on the features of Savant and gain more users.

Tags:
Savant