Fork us on GitHub

Automating Releases

Using special build options to make releases easy
Automating Releases

Automating Releases

Our website deployment has become even more complex thanks to the demos section. The crux of it is in updating the demos with every small update to the JavaScript build process which is why we implemented a build option based on the work we did for our CI (Jenkins) integration. This work essentially allows to build a Codename One app synchronously which is useful when you want to do things such as continuous integration or release engineering.
Notice that the synchronous build feature is an enterprise only feature since its overuse can have a very heavy toll on our servers.

Essentially we copied the existing build.xml to a separate file to prevent updates from overriding it. We then added targets such as this for the kitchen sink:

<target name="build-for-javascript-sync" depends="clean,copy-javascript-override,copy-libs,jar,clean-override">
        packageName = "${codename1.packageName}"
        mainClassName = "${codename1.mainName}"

This is effectively a copy and paste of the build-for-javascript target where we added the line automated="true" to indicate that this build works in a singular process.
After the build completes we are left with a file in the dist folder. Which we unzip to find all the files from the build server:

<mkdir dir="build/demoTmp/unzipped" />
<unzip src="build/demoTmp/${demoname}" dest="build/demoTmp/unzipped" />
<delete file="build/demoTmp/unzipped/index.html" />
<copy  todir="demos/${demoname}">
    <fileset dir="build/demoTmp/unzipped"/>

While the sample above shows the JavaScript build target it can be applied to any of the Codename One build targets and is remarkably useful for a release engineering process. When you need to release one version for all platforms on a frequent basis even a minute automation like this makes a big difference.

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.