Colorised Build Success Message

My current project has a neat trick we picked up where the build has a red or green banner at the end when you run it locally to give good feedback about the build status. I’m not sure who originated it, but thanks!

I just had to tweak it a bit to get it working on OS X so I thought I would document the trick here.

run.sh - OS X

CMD=”./tools/ant/bin/ant -lib ./asl/lib/jdepend $@”
echo “Running command [${CMD}] …”
$CMD
if [ “$?” -ne 0 ]; then
    echo -e “`tput setab 1`  `cat ./ci/failed.txt` `tput setab 0`”
    exit 1
else
    echo -e “`tput setab 2`  `cat ./ci/passed.txt`  `tput setab 0`”
    exit 0
fi

This assumes you have two supporting files ./ci/passed.txt and ./ci/failed.txt which contain the message. You can generate messages to your taste here.

I have provided the files in this example here :

passed.txt

failed.txt

It has also been run under Ubuntu where the following works (it didnt work on OS X which is why I adapted it), but the tput should also work on Ubuntu. I’ve not explicitly tested this one!

if [ “$?” -ne 0 ]; then
    echo -e “\E[30;41m”
    cat ./ci/failed.txt
    echo -e “\E[0m”
    exit 1
else
    echo -e “\E[30;42m”
    cat ./ci/passed.txt
    echo -e “\E[0m”
    exit 0
fi

Under windows you can actually make the entire screen of the terminal change color:

run.bat - WINDOWS

CALL tools\ant\bin\ant %*
IF ERRORLEVEL 1 GOTO RedBuild
IF ERRORLEVEL 0 GOTO GreenBuild
:RedBuild
color 4F
GOTO TheEnd
:GreenBuild
color 2F
:TheEnd
PAUSE
color 07
Share

Java Sources (src.jar) for JDK on OSX

I just discovered that I don’t have the src.jar for my JDK installation and took a bit of ferreting about to find out that you need to download and install the JDK documentation bundle from apple developer site, aswell as the actual jdk.

You can see the thread I found here

The downloads for both the JDK and the associated documentation live here login and go to downloads. You want “Java for Mac OS X Release X” and “Java for Mac OS X Release X Developer documentation”

It then lives in (e.g) /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home

Share

MacWidgets – Java Swing looking native on OS X

I just discovered Exploding Pixels’ MacWidgets. Its a beautiful library. Literally just pasted a couple of lines of code into my Java app and now it looks right at home on the os x desktop. I’m running JDK 1.6 on Leopard.

Here is is in action:

macwidgets-demo

And here is the code (its been edited slightly so may not copy and paste, but you get the idea) …

 
        MacUtils.makeWindowLeopardStyle(getRootPane());
 
        UnifiedToolBar toolBar = new UnifiedToolBar();
 
        JButton button = new JButton(“My Button”);
        button.putClientProperty(“JButton.buttonType”, “textured”);
        toolBar.addComponentToLeft(button);
 
        getContentPane().add(toolBar.getComponent(), BorderLayout.NORTH);
 
        BottomBar bottomBar = new BottomBar(BottomBarSize.SMALL);
        bottomBar.addComponentToLeft(MacWidgetFactory.createEmphasizedLabel(” Status”));
 
        getContentPane().add(bottomBar.getComponent(), BorderLayout.SOUTH);
 
Share

iTerm – Upgrade your Terminal

Spending a lot of time in various ssh sessions?

A bit tired of trying to remember which tab is on which server with the default os x terminal ?

So was I. Hunting around, I saw various hacks (e.g. a bash script, or applescript) to achieve this but also an app called iTerm.

Its free and within 30mins I was pretty much back to my previous terminal existence but with the names of my servers and my username in the tabs titles.

Awesome.

Some things I learned:

1) Some of the preferences I had to hunt for:

Not everything is available from iTerm–>Preferences. There are a couple of menu options of interest (this is iTerm 0.9.6).

View–>Show Session Info …

This lets you change the colors and fonts, etc for your terminal window and also update the default.

Bookmarks –> Manage Profiles …

This is where you can set a lot more options about your session, including making the cursor blink (Something for some reason I found essential:)

The reason they are here is because they are associated with bookmarks, a powerful feature that for example allows you to bookmark an ssh session, and have a whole set of preferences associated with that session.

I would like to see them all aggregated under the “Preferences” option though, because as a os x user, thats where I expect to find everything that I can configure (Posted as an feature request.

2) I wanted the title to change whenever I change directory. Simple, just need the following in my ~/.bash_profile (see here for differences between ~/.bashrc:

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\007"'

3) This one is not probably very “good form”, but I really like the icon for the os x terminal window. So simply “Show Package Contents” on the iTerm.app and swap out /Contents/Resources/iTerm.icns with the equivalent in the Terminal application Terminal.icns

4) I also wanted a “close x” icon on each tab, and discovered that this is under Preferences –> Tab –> Use compact tab labels. You want to UN check this.

I now have exactly the same user experience as before with some great bonuses, for example, a cool feature is the “blur” of the transparency behind the window.

Share

IntelliJ Crashes on OS X

I have been running v.8 of IntelliJ on os x for a while now, and noticed the odd crash, particularly after waking up the computer.

Thanks to my colleague Tom Czarniecki I have found a solution that appears to be working.

Some googling turned up very little, but mostly points to the JVM being the problem. I had tried updating the Java installed on os x and setting the JDK to be 1.5 which did seem to improve stability but still crashed.

Tom pointed out that Intellij also has a configuration for the JDK version in its config which I updated to be 1.6+ and then switched my JDK back to 1.6 64bit. That was a week ago and not only have I had no crashes, of course the whole experience is smoother under 1.6! woo hoo!

The trick lies in the file

/Applications/IntelliJ IDEA 8.1.3.app/Contents/Info.plist
<key>JVMVersion</key>
<string>1.6*</string>

To Switch JDKs:

/Applications/Utilities/Java/Java Preferences.app

Some other references I found along the way:

http://www.jetbrains.net/devnet/thread/282406

JDK Update:

http://www.apple.com/downloads/macosx/apple/application_updates/javaformacosx105update4.html

To See IntelliJ Log output:

~/Library/Caches/IntelliJIDEA8x/log/

UPDATE:

For Intellij9:

/Users/jim/Library/Logs/IntelliJIdea90/idea.log

(I found this using the activity monitor and then “inspect process” and you can see a list of open files and ports)

IntelliJ stores its plugins here (Thanks to these guys) :

~/Library/Application Support/IntelliJIDEA80

Share