Postgresql > 9.2.x JDBC drivers don't work (only from gradle) with groovy

I’ve seen similar posts here, but most involved running queries from the build script. I’m trying to run a simple groovy script and add the JDBC prostgres driver to it.

I have a build script like this:

apply plugin: "groovy"

repositories {

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.12'
    compile 'org.codehaus.groovy:groovy-all:2.4.4'
    runtime 'postgresql:postgresql:9.1-901-1.jdbc4'
    // runtime 'org.postgresql:postgresql:9.4-1202-jdbc4'

task runScript (type: JavaExec){
    description 'Run Groovy script'
    main = 'Script'
    classpath = sourceSets.main.runtimeClasspath

defaultTasks 'runScript'

and a script like this:

import groovy.sql.Sql

def sql = groovy.sql.Sql.newInstance("jdbc:postgresql://", "postgres","password", "org.postgresql.Driver")
println sql

If I use ‘postgresql:postgresql:9.1-901-1.jdbc4’, everything is peachy. But any newer version, such as ‘postgresql:postgresql:9.1-901-1.jdbc4’ tells me to appropriate driver is found:

gradle                                                                                                                                  sgates@Steffens-Retina-MBP
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:postgresql://
	at java.sql.DriverManager.getConnection(
	at java.sql.DriverManager.getConnection(
	at groovy.sql.Sql.newInstance(
	at groovy.sql.Sql.newInstance(
	at groovy.sql.Sql$ Source)    

Now, if I run the same code from groovy directly and use grab instead, everything works fine:

import groovy.sql.Sql

def sql = groovy.sql.Sql.newInstance("jdbc:postgresql://", "postgres","password", "org.postgresql.Driver")
println sql

The only thing that seems to distinguish the <9.1.x and >=9.2.x lines is that they changed the maven group id from prostgresql:postgresql to org.prostgresql:postgresql. I can’t see how that would matter. Did something else happen with 9.2.x that would cause gradle to get hung up on the classpath? Printing the class path from the script seems normal:

/Users/<my name here>/Desktop/postgres/build/classes/main:/Users/<my name here>/Desktop/postgres/build/resources/main:/Users/<my name here>/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.12/8e20852d05222dc286bf1c71d78d0531e177c317/slf4j-api-1.7.12.jar:/Users/<my name here>/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy-all/2.4.4/b22748b6cf9a38c9777792175507a679043cdd64/groovy-all-2.4.4.jar:/Users/<my name here>/.gradle/caches/modules-2/files-2.1/org.postgresql/postgresql/9.4-1202-jdbc4/541a27139976fc3d7ecd15916404a49536e55b3f/postgresql-9.4-1202-jdbc4.jar

Can anyone reproduce or give me a hint? I’m using groovy 2.4.4 with java 1.8.0_60-b27 on MacOS 10.10.5.

Thanks Guys!