Grails Release Plugin External Maven Config

The grails release plugin is great for publishing plugins to grails central but it will also publish a plugin to a maven repo. You simple need to configure the new maven repo inside build config. But if you want to release snapshots to an internal maven but not have that config checked in publicly that is a bit more tricky. With a quick bit of code added to BuildConfig.groovy we can have it pull in the config from a file we can choose to not checkin. Now with our public code we don’t need to expose our internal login info. See the file changes below for an example.

Add this to BuildConfig.groovy:

    def mavenConfigFile = new File("${basedir}/grails-app/conf/mavenInfo.groovy")
    if (mavenConfigFile.exists()) {
    	def slurpedMavenInfo = new ConfigSlurper().parse(mavenConfigFile.toURL())
    	slurpedMavenInfo.grails.project.repos.each {k, v ->
    		println "Adding maven info for repo $k"
    		grails.project.repos."$k" = v
    else {
    	println "No mavenInfo file found."

Then you can create a file called mavenInfo.groovy:

    grails.project.repos.internalSnap.url = ''
    grails.project.repos.internalSnap.username = 'fakeUser'
    grails.project.repos.internalSnap.password = 'fakePass123'

Grab the gist.

Grails Redirect Leaving %2F in URL

I am using a simple redirect after a user logs in so they can get to the page they were heading too the URLs were ending up with %2F in the url which caused a 404 error. The problem wasn’t actually in Grails at all but in the mod_rewrite rule being used to force HTTPS connection the rule was set up to end with [L,R] when to correctly deal with the url encoding we were already doing it needed to be [NE,L,R]


jQuery serialize() and Form Example Plugin

When working with jQuery 1.6.1 and the jQuery Form Example Plugin I found that the examples were being serialized the plan was to use Ajax to send the serialized data back to the server and save it but I didn’t want to have to try and remove the examples server side. So triggering unload on the examples will allow serialize to get the correct data. Example JavaScript below.

    var examples = $('.example');

I used Userscore.js to give me a quick foreach style loop and called the unload event on every element that has the class .example which is the default class that jQuery Form Example plugin uses.

Java and JavaScript Datetime Fun

So dealing with Datetime between client and server side can always be fun due to timezones but adding a number of browsers makes it all the more complicated. For our project we are using Joda-Time on the Java side and a mix of technologies on the client side (I will be addressing that soon). So we deiced to pass all datetimes via ISO-8601 the problem came when dealing with the different browsers. IE7 and IE8 both output a string that doesn’t have the milliseconds where Chrome and FireFox did.

On the Java side we used ISODateTimeFormat.dateTime() to parse the incoming date string so we wanted the milliseconds.

To make this work I made a quick JavaScript utility that I can use to output the correct format in UTC time as we wanted. You can see the code below.

Its rather simple just using the UTC versions of getting the date and time elements I construct a string that will be ISO-8601 formatted. I have tested this in IE 7, 8, and 9 Chrome and FireFox. If there are any issues feel free to comment and I will do what I can to help.

Check for Address Bar in iOS

As we know how to hide the address bar in iOS, we may want to tell if a user has that bar showing or not. I use this detection to show instructions to the user to add a site to their home screen if they are not in stand alone mode.

There are two properties we want to look at “standalone” in window.navigator and window.navigator.standalone. We can use the first expression to check if the device supports full screen mode and the second to check if it is in full screen mode. I have checked these with the iPhone and iPad, with iOS versions 3 and 4 if anyone has any issues please post a comment and we can try and work through it.

The following checks will after the page is loaded output to the console the mode its in. From there you can easily replace the console.log with what ever functions you would like.

There is a great write up by Ben Nadel you can find over at his blog. Post