Monday, November 29, 2010

Building an iOS project with Hudson

I'm mostly writing this here for archival purposes. This is how I used to build iOS projects via Hudson (I don't have any iOS projects ongoing).

First, since Hudson runs on a Linux machine, I need to add a new node then start the agent on an OSX machine from an account where I have all the digital keys set up properly.

Next, supposing I have an iOS app called Example, I just tell Hudson to poll the SCM then execute the script:

TIME=`date "+%Y-%m-%d_%H-%M-%S"`;


rm -r build || true;


xcodebuild -target Example -configuration Distribution -sdk iphoneos3.1.2 clean build


  && 


  (mkdir build/Distribution-iphoneos/Payload; mv build/Distribution-iphoneos/Example.app build/Distribution-iphoneos/Payload)
  
  && 
  
  (cd build/Distribution-iphoneos && zip -9 "example-$TIME.ipa" -r Payload)

Afterwards Hudson just needs to "Archive the artifacts" from build/Distribution-iphoneos/*.ipa


Obviously you need to tweak the sdk version a bit as this script is for an older 3.1 app but this is the gist of it.

Now you just have Hudson doing builds as soon as a commit comes up and you can send updates to customers by just grabbing the .ipa file from the Hudson site (or even give customers direct access to Hudson and have them download a build as soon as available).

Friday, November 26, 2010

NetBeans Slowness detector with Growl

Got surprised today when I saw the slowness notification on Growl:


I rarely get this message but it's nice to see it published via Growl, using my OSX Notifications module which is a Growl bridge for NetBeans Platform notifications.

Clicking on the notification


gets you this:



I'm not entirely satisfied with the way this message is presented because I would need a "Close" button, not an "OK" button. Also -- clicking on that hyperlink seems to open a new window behind this dialog.

Anyhow, there isn't much I can control since we have a lot of native components due to the broken OpenIDE AWT NotificationDisplayer API which encourages custom JComponents.

This particular notification for example should use no custom component. It should just say: "Slowness detected: Not responsive for 5 s" and then clicking on the (Growl) notification should open the "Report Problem" dialog.

Wednesday, November 17, 2010

NetBeans Growl notifications

Demo time



This plugin provides Growl integration with NetBeans. If you are using NetBeans on OSX and you have Growl, download my plugin.

As a proof of concept builds are shown but all other notifications that usually would have appeared using the default implementation are now posted via Growl.

Complex UIs trigger just a simple notification and then display a dialog when clicked with the actual custom components (obviously one can't publish custom Swing components in a Growl popup).



Speaking of complex UIs, some custom components are just JLabels that simulate hyperlinks so I would say those might be migrated to a normal text and ActionListener.

Background

One thing that NetBeans needs is OS-aware notifications and my two focused OSes are Ubuntu and OSX.

On Linux we have the Desktop Notifications Specification, which is a very clean, D-BUS based specification for desktop-wide notifications.

Ubuntu extends and modified the specification a bit as well as define a quite nice design guideline document.

Growl defines the OSX notification standard which is generally similar to the Ubuntu version. Their documentation provides a nice overview of their API.

NetBeans on the other hand has its own notification API in the via the OpenIDE AWT NotificationDisplayer API.

The problem is that all these are disconnected, but rather similar given the nature of the problem they are trying to solve.

What I think NetBeans is missing on OSX is a proper Growl bridge. Also, the NetBeans API should be modified to discourage custom components as those aren't easy to bridge to something else.

Implementations

It's rather hard to find Java bindings for Growl as the official implementation is deprecated.

Next, I was able to find Grrrowl by Sonatype, which uses native code (via HawtJNI) and seems to be originally part of IntelliJ. There's also a fallback implementation to AppleScript which is nicely provided as pure Java scripting engine on an Apple JVM.

The problem with Grrrowl is that while it does display notifications quite nicely, it doesn't support any click handlers, so we won't be able to respond to user interaction.

The best implementation seems to be a very low-profile implementation by Michael Stringer, posted as stringbean on CocoaForge.

Michael Stringer's version uses actual JNI and provides a click handler. This is what my implementation uses.

Obviously, it only works on OSX, specifically, Intel-based OSX (because that's what I used to build the native code).

Let me know what do you think about it.

Monday, November 01, 2010

MySQL as the first NoSQL database

I was watching yesterday a presentation at GeekMeet Timisoara about how to scale your websites and all the MySQL-related advices were as expected, but upon thinking about it, entirely agains normal database mantras:

  • You should de-normalize the database (copies are easier to access and cheap)
  • You should disable transactions (ie. use a MySQL storage engine that isn't transactional).
  • MySQL Master-Slave replication (which is asynchronous!)

This made me realize that MySQL is successful precisely because of all the things I discredited it for.

You see, in my book MySQL was never a real database because, initially, it wasn't transactional. For the project where I could choose the database, I picked PostgreSQL and I always used MySQL knowing in the back of my head that, in fact, it was a bit of a sham.

But this might just be MySQL's good fortune: by providing a simple storage engine with some SQL front-end, they proved that most people don't need ACID compliance.

Furthermore, as more and more people need to scale their applications horizontally (since it's cheaper and because... Google does it), they need even less of an actual database.

NoSQL was a movement that started after people got tired of the constraints of SQL databases and started thinking about what do they really need when storing data. It was liberating to see that one must not assume from the start that "external data==database" and actually put some though into the specific needs of their application.

And by being such a lightweight and unconstrained implementation, MySQL is right here, still serving the needs of people that want to scale out.

MySQL was basically the first NoSQL database. By relaxing what a database must provide, they proved in the long run that this is what people actually need. So besides the pure NoSQL tools like the various key-value stores they are building nowadays, MySQL could very well remain the most used place to store your data precisely because it allows you to pick which of the database-specific features you actually need.