Shizzle

My little notebook

Mavens’s “The artifact has no valid ranges”

October 10, 2009

I have just learned to use the really great Java build and project management tool Maven. It makes managing large projects with dozens of components a lot easier and its build configuration is simpler and less imperative compared to Ant, since it relies a lot on convention over configuration. Basically, Maven knows that pretty much every project needs to be

  • compiled
  • JavaDoc’d
  • unit tested

These things don’t need to be declared and are automatically done by Maven. Maven’s great advantage over Ant is it’s ability to handle the dependencies of your project, ie. the old “Hunt the JAR” game is a thing of the past as Maven will simply download whatever libraries or frameworks you will need. Most of the time your build will run smoothly and Maven will spit out a nice JAR or WAR without problems.

The curious error message

However, if there are build errors they tend to be on the cryptic side. “The artifact has no valid ranges” is one of those. Basically it means that you do have a valid range, however you have defined two (or more) different version ranges of an artifact in a fixed way. Most likely you haven’t defined those dependencies in the same project but through a transitive dependency.

Let’s have an example. Your project my-app, depends on an artifact super-framework at version 1.0, and only 1.0, nothing else. my-app also depends on another of your apps called my-app2. my-app2 has a dependency on super-framework but only for versions 0.5 to 0.9. This means that you have incompatible version ranges and you need to resolve this. You will have to edit my-app or my-app2 and change their version ranges for super-framework.

This took me a little while to figure out myself since the error kinda suggests to look in the wrong place. The range is perfectly valid, it’s just that there is too many of them.

Debugging this message

That is a little tricky. You can try running Maven with the -X flag, which will show a running log of how the version is chosen. Also, sometimes the Maven plugin for Eclipse can give you some clues, but sometimes it is way off.

One word of advice though, it seems to matter in which order you include your dependencies in the the POM file. So, if you include a dependency on

super-framework [0.5,1.5)

it will fetch the latest available version, say 1.1.

If you then have a transitive dependency further down that includes

super-framework [0.5, 1.0)

Maven will generate this misleading error, since it will not select anything other than the 1.1 it already has, even though it could just select 0.9 without producing a version conflict. If you swap the order, weirdly, it works.

No Comments

First impressions of OS X 10.6 Snow Leopard

September 8, 2009

I couldn’t wait to finally get my hands on a copy of the latest iteration of Apple’s OS and the postal strike here in the UK made matters worse.

Last Saturday the disc finally arrived! It didn’t take long to upgrade the system from Leopard and the process was smooth and polished – almost zero user input required as we are used form Apple.

Now to the actual OS: Well, startup and shutdown is noticeably faster but to be honest I couldn’t see a massive speed up in the main system. To be fair, it was pretty speedy on Leopard already and I never had the feeling that it was sluggish; therefore it probably went  from pretty fast to very fast and maybe that difference isn’t so big.

Lets get to the improvements. These aren’t earth-shaking but many of them fall under the category “Oh, that’s nice”.

  • Working CD/DVD burning support: This was a major gripe of mine on Leopard. Disc writing would often fail and Disk Utility was awful for burning – Leopard’s “burn folders” never worked either. If that wasn’t such a basic thing I would say “Well Done” to Apple but this should have been way better a long time ago.
Snow Leopard disc burning

Snow Leopard disc burning

  • Expose is more useful. Instead of the old seemingly random positioning of the windows they now arrange themselves on a grid and the dock and the menu bar turn black which I like better. Also, if you click on an active dock icon and then hold you can see all the windows that the program has open at this point in time.
  • Dock stacks are scrollable. Again this really isn’t a killer feature.
  • Address Book can sync with GMail. I’m liking that.
  • Quick Time looks nicer. I’m not quite sure what has happened under the hood there but I like the new interface. Just get yourself Perian and it is almost as good as VLC.
  • Mail supports Exchange server. Even though I didn’t test this, as I use neither, this could come in handy. It also means that Exchange server is better supported out-of-the box on OS X than on Windows – go figure.

Apparently, there is all sorts of stuff happening with Grand Central and OpenCL but I rarely have an application that is heavy on either CPU or GPU so this doesn’t really matter to me but is nice to know. Almost all of my programs still worked fine under Snow Leopard; the only one where I had to use a beta version is Cyberduck.

There is one little gripe: I used to have a developer preview version of Safari 4 which allowed websites to be saved as a web application which then had it own dock icon (and presumably its own process). I assumed this feature was held back until Snow Leopard came out but I can’t seem to find it. Hmm.

Baseline

I like it particularly for the fact that it isn’t jam-packed with features that no-one needs but is a good solid exercise in improving the core of the system. I got this update for £10 and I think even £30 would be no-brainer for all Leopard users. I don’t think I would pay the full retail price (£129.00 for the box set with iLife) for it though.

No Comments

Converting transparent PNGs for use with LaTeX

August 31, 2009

I have recently discovered the power and ease of use of LaTeX and in my last report in included quite a few screenshots of the application I was writing. However OS X’s screenshot tool also saves the nice drop shadow that the UI produces around it’s windows.

LaTeX on the other hand, doesn’t seem to like those drop shadows as they contain transparency (also know as alpha channel) which after the conversion to PDF appears as ugly black borders. Fortunately there is an easy fix for this problem, which I found in a mailing list message.

You will need to have ImageMagick installed for this to work. ImageMagick’s convert command line tool allows you to convert the transparent part into proper colours rather than a grey layer with added transparency information (which is what throws the tex-to- PDF converter). Before you add those images to the tex file, convert them like this:

convert -background white -layers merge input.png output.png

1 Comment

Changes to submitting measurements to Edd

August 29, 2009

I have made some changes to how submitting measurements works in my spoke length calculator, Edd. Up until now submission was anonymous, which had the obvious drawbacks of verification and me being unable to ask for clarification if a submission was unclear.

From now on you will have to supply an email address if you want to submit measurements for a hub or rim, but please be assured that this data will be for my eyes only. I won’t spam you or won’t give your email address to anyone.

4 Comments

In praise of Netbeans (and how I learned to hate Eclipse)

August 10, 2009

The dark ages

I use a MacBook for my development and until recently I have done my Java development in Eclipse. It is a very popular IDE and apparently very flexible and can be made to do absolutely everything. Also, all the Google Java products plugins only worked for Eclipse and that was the main reason for me to not switch.

However, it shortcomings became more and more apparent during the time I wrote my dissertation and became more serious about Java development. I noticed the following things about the OS X variant of Eclipse.

  1. It. Is. Slow. It is painful to work with an IDE that locks up every 5 minutes and whenever you open a menu that has so far not been opened. I heard something about the Java-Carbon bindings not being very good and I think performance is better on Windows but this was a real issue for me.
  2. Usability is abysmal. There are millions of message areas that pop up all the time, buttons are tiny and appear and disappear seemingly randomly. I know software development is supposed to be difficult but this is just unbearably hostile to the user.
  3. It is very much a Windows app. It feels a lot like they wrote the app to fit with the windows UI guidelines, realised that there is Mac developers too and just copied the UI button by button. I know us Mac people are demanding when it comes to OS integration but Eclipse is simply not cutting it.

The conversion

One day I was frustrated enough by how rubbish Eclipse was, that I was ready to switch IDE mid-project. I kept saying to myself that I would give Netbeans a spin at the next project but my patience with Eclipse was wearing thin. I have not looked back.

The main issue I was worried about was the project conversion process and I have to tell you it was the most seamless thing I have ever experienced. Absolutely no errors or incompatibilities turned up. I was impressed. It also turned out that Netbeans is much better at managing your classpath automatically, so conversion even resolved a few issues. The only thing I had to redo was the tomcat configuration but that took about 30 mins.

I didn’t know Java development could be bearable on a Mac

After trying Netbeans out for a few days I have the following things about it.

  1. It has a nicer UI. I know this will not get me any cred with the emacs crowd but if an application doesn’t shout “I’M UGLY!” all day long I like using it better than one that does. Call me superficial.
    I also managed to install a dark editor skin which makes Netbeans resemble Textmate a bit more which has also earned some plus points with me.
  2. Usability is way better. Buttons are clear and there are fewer of them. Netbeans also gives you more sane default behaviour so you don’t have to poke around in the settings too often.
  3. Classpath and lib folder management works. When you put something in the lib folder, it will be put on the classpath and copied into WEB-INF/lib. I couldn’t get Eclipse to do that no matter how hard I tried. I had to enable this for every JAR I downloaded.
  4. It’s faster. Not Textmate-fast but fast enough to not annoy me constantly. I like.
  5. Mercurial works out of the box. I didn’t install a plugin, I never activated anything. Netbeans just knew I was using it and started marking files as edited. (I guess this works for other SCMs too.)
Netbeans screenshot with Textmate style dark theme

Netbeans screenshot with Textmate-style dark theme

In retrospect, switching to Netbeans has been a huge boost in terms of productivity for me. I’m wondering why I didn’t try it earlier.

7 Comments

How to set OpenDNS as the DNS provider for your Speedtouch router

July 18, 2009

Here is a really neat trick on how to speed up your home internet quickly and for free.

A little background

Basically every time a browser requests a page from an human-readable address like google.com, it first needs to find out the IP address for the server. This lookup takes some time and is provided by DNS servers. However, most ISP’s DNS servers are slow because no one asks “How fast is the DNS lookup?” when they shop around for broadband.

OpenDNS

OpenDNS is a free service that does faster DNS lookup than your broadband provider. They finance themselves by showing you a suggestions page when you mistype an address and this suggestions page has some ads on it. For me that isn’t obstructive at all.

How to do it

The Speedtouch routers don’t have a GUI for changing the DNS servers so you need to login via the command line program telnet into the router, which by default has the address 192.168.1.254 . If you have changed the IP address of your router you will need to use that instead.

telnet 192.168.1.254

The default user for Speedtouch routers is Administrator and the default password is just blank. Obviously if you changed these setting then you’ll have to enter those details.

Now you need to issue three commands which change the DNS settings. First delete the old DNS settings:

dns server route flush

Then add the two OpenDNS ones:

dns server route add dns=208.67.222.222 metric=1 intf=RoutedEthoA
dns server route add dns=208.67.220.220 metric=1 intf=RoutedEthoA

Now save everything with

saveall

That’s it. Try it out now by mistyping an address, if you can see the OpenDNS page then you’ve done it!

No Comments

A fast and free Safari “plugin” for delicious.com

May 2, 2009

Having changed over from Firefox to Safari recently, I sorely missed a free and fast delicious.com plugin. Then I spotted a new feature of WebKit, Safari’s open-source underpinnings: HTML5 offline database storage. This allows Safari to have a local copy of all your public delicious bookmarks, which are superfast to search too.

If you want to try it out visit http://lenni.info/tools/overdrive/.

Well, the title is a little misleading. It isn’t really a plugin; it is a little web app that makes use of advanced browser features. Initially, this site will only download the last 100 bookmarks but over time all of your bookmarks will be downloaded – just leave the window open for a few minutes. To search your bookmarks, just enter your search term into the search box at the top.

I have placed an intentional restriction on the application. You can’t download your private bookmarks since that would mean you’d have to enter your Yahoo password into the site, which should make you nervous.

If you notice any quirks, send me an email or post a comment here.

06/07/2009:
I have made two updates to the app: Firstly, you can now search for two or more search terms, ie “banking online” will now search for bookmarks that match “online” and “banking”. Secondly, the annoying behaviour of the bookmarks appearing at the bottom of the list during the download is gone too. Use Shift+Reload in order to clear your cache and to get the newest version of the app.

I also fixed a little bug where sometimes a wrong tag list was being downloaded. If you have the feeling that some of your bookmarks are missing, please reset the app.

14 Comments

How to “inject” the current mercurial revision into your JS load requests

March 29, 2009

When you do web development you will soon have to find a way to force users to download a new version of your JavaScript files before their browser cache actually requires it. The best way to do this is just add a made-up GET argument to the file name when you load the script and change this when you upload an new version of the script.
It should look something like this:

<script src="behaviour.js?revision=14" type="text/javascript"></script>

One of my JavaScript “build scripts” has this one automated and reads the current revision from my mercurial repository of this project. In order to just get the revision number type this in the console when you are cd’ed into the project folder (I recognised that this is not the most elegant of bash scripting, but it will do the job):

hg log -l1|grep changeset|grep -o  "\([0-9]\+\):"|grep -o "\([0-9]\+\)"

In your HTML files you will need a little placeholder that will mark all those places where the current revision number should be injected. I chose the string {REV}. Your HTML header should look like this:

<script src="behaviour.js?revision={REV}" type="text/javascript"></script>

Now, the next step replaces all occurrences of the string {REV} with the number of the current mercurial revision. The following script takes one argument: the filename (or file pattern) that should be scanned for the string {REV}.

#!/bin/bash
export rev=`hg log -l1|grep changeset|grep -o  "\([0-9]\+\):"|grep -o "\([0-9]\+\)"`
echo "Replacing all occurences of {REV} in $1 with the current hg revision "$rev
perl -pi -e 's/{REV}/'$rev'/g' $1

So put this code in a file, say, replace.sh, make it executable and then run it with something like

./replace.sh index.html

3 Comments

Let Google host jQuery for you

March 15, 2009

If you want to make use of Google’s hosting platform for all sorts of JavaScript libraries and want to use jQuery in your site, just insert this snippet into the header of your HTML document.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>

This blog post explains why Google hosting is a Good Idea.

Addition

We have started using Prototype and script.aculo.us at work. Here’s Google’s URL for it:

<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"><!--mce:1--></script>
<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js" type="text/javascript"><!--mce:2--></script>

1 Comment

TinyURL bookmarklet

February 28, 2009

Do you love TinyURL but wished that there was an easier way of creating your shortened URLs? Here it is: I have written a little bookmarklet which is heavily influenced by the delicious one.

Just drag the following link to your bookmarks bar:

TinyURL!

Let me know how it is working in the comments.

No Comments