Getting started

In this short tutorial I will show step by step how to create a ready-to-deploy installer for your Java product using BuildDesk. For the demo project I selected a small tool, called GMosaic, I developed some time ago (more on that read in my blog: post #1 and post #2). This is a perfect candidate for our task: it is small and it is a desktop application. Full source code along with IDEA project can be downloaded from http://www.skavish.com/gmosaic.

  1. Ok, now let's start BuildDesk.
  2. Since it's a first time we run BuildDesk we need to import our GMosaic IDEA project into BuildDesk. Click Import IDEA project link and select GMosaic project file.
  3. Our IDEA project has almost all the information to succesfully build our product, but not everything. For example location of JDK is stored in IDEA configuration files, not in the project itself. Naturally BuildDesk needs to know where IDEA is installed, so it may find all the missing stuff. Just specify IDEA installation directory in this dialog.
  4. Now we have our project imported into BuildDesk. Here we have several screens:
    • Welcome - where you open existing project and import new ones
    • Layout - where you specify how product layout will look like and move files from project to product layout
    • Obfuscation - where you control obfuscator settings
    • Packaging - where you specify various options for installer
    • Settings - where you control build process itself
    • Flow - where you may customize build with your own tasks
    • Run - final screen to generate Ant build file and to buld your product
  5. First thing we need to do is to define where to put all our classes and libraries and how directory structure should look like when our product is installed on user's computer. Since our test project is very simple we can put all our classes and resources into one jar. Let's call it gmosaic.jar and place it into our installation root. To do that right-click on gmosaic Installation root and select Add Jar:
  6. Name this jar gmosaic.jar:
  7. Now we need to drag all our classes and resources into that jar. Select resources and src:
  8. and drag them right into our jar:
  9. You can see now that both our sources (resources and src) are placed into gmosaic.jar:
  10. Now we need to specify where all the libraries our project uses should go. I usually put all the libraries into separate directory named: lib. Let's do it with BuildDesk. First create a new directory in the installation layout in the same way as we created our jar: right-click on gmosaic Installation root, select Add Folder and name it lib:
  11. Then switch to Library Deps tab in Imported Project panel:
  12. Select all the libraries our project need (we need all of them) and drag them to our new folder lib in installation layout:
  13. Now we have all our libraries placed under folder lib in installation layout:
  14. We need to make our gmosaic.jar startable and specify which class is main class. To do that select gmosaic.jar in installation layout and in properties panel under the installation layout tree select Make startable checkbox, select our main class and select Add every jar to classpath checkbox:
  15. You might have noticed that there is some Warning shown in the bottom left corner of our window. That's how BuildDesk tells us about any problems with our layout. Click on that Warning icon. Here BuildDesk warns us that we have not specified start jar which is used to launch our product.
  16. Double-click on that warning and BuildDesk sends us to Packaging screen where we should enter which jar will be startable. Notice small exclamation-sign icon in the Startable jar text field. It indicates that there is a problem.
  17. Click on browse button next to Startable jar text field and pick our gmosaic.jar.
  18. Since we are on Packaging screen let's see what other settings we need to change for our application. First option I select is JRE bundling. This product may be used by people who know nothing about Java, so it seems to be the right choice. Then I specify maximum heap memory to be 500Mb. Our application deals with huge images and naturally is memory hungry. The only other option I change is splash file. I want GMosaic to display nice splash screen when it starts.
  19. Now let's switch to Obfuscation screen. Our project contains some Now How (it does not btw :)) which we don't want to reveal to anybody. To make life harder for our competitors we need to obfuscate our code. All we need to do is switch to Obfuscation screen and select gmosaic.jar for obfuscation:
  20. We are almost done! The only thing left is to actually build our product. To do that switch to Run screen and click Run button. BuildDesk will generate ant build file and then run it automatically. The Ant file will compile our classes, obfuscate them, then layout all the jars and libraries according to our instructions and finally it will build installer for Windows, Mac OS and zip for Unix.
  21. Check your console for any errors. If everything is ok you should see Build successful:
  22. Click on this link:
  23. It will open directory containing our installers:
  24. Can you believe how simple it has been?! In just under 10 minutes we produced Ant script which correctly compiles our project, packages all the classes into jars, obfuscates the jars, then puts our jars along with libraries and all the files into installation layout, creates Windows native launcher and native installer, Mac OS X installer and generic zip! Isn't it amazing! Now go and import your own project!