Skip to content

Instantly share code, notes, and snippets.

@bdkosher
Last active August 29, 2015 14:01
Show Gist options
  • Save bdkosher/bcc06367c2be75663438 to your computer and use it in GitHub Desktop.
Save bdkosher/bcc06367c2be75663438 to your computer and use it in GitHub Desktop.
A Groovy script to indy-enable a Groovy SDK, sans auto-applying the --indy flag in the GROOVY_OPTS.
// For moving jars in order to take advantage of Groovy's indy feature
def groovyHome = args.length == 0 ? new File('.') : new File(args[0])
def libDir = new File(groovyHome, 'lib')
def indyDir = new File(groovyHome, 'indy')
if (!groovyHome.exists() || !libDir.exists() || !indyDir.exists() || !new File(groovyHome, 'bin').exists()) {
println "$groovyHome does not appear to be a valid Groovy Home"
System.exit(0)
}
println "Backing up existing groovy jars in $libDir..."
libDir.eachFileMatch(~/groovy\-.*\.jar/) { jar ->
jar.renameTo(new File(libDir, jar.name + '.off'))
}
println "Copying indy groovy jars from $indyDir to $libDir..."
new AntBuilder().copy(todir:libDir) {
fileset(dir:indyDir) {
include(name:'**/*-indy.jar')
}
}
println "Renaming indy groovy jars..."
libDir.eachFileMatch(~/.*indy\.jar/) { jar ->
jar.renameTo(new File(libDir, jar.name - '-indy'))
}
println "$groovyHome SDK is now indy-ready."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment