Skip to content

Instantly share code, notes, and snippets.

@objectx
Created June 14, 2013 13:21
Show Gist options
  • Save objectx/5781757 to your computer and use it in GitHub Desktop.
Save objectx/5781757 to your computer and use it in GitHub Desktop.
InvokeDynamic enabler for Groovy on windows. Place it on <groovydir>/bin and run.
#
# indynize.ps1: InvokeDynamic enabler for Groovy on windows.
#
# AUTHOR(S): Masashi Fujita <objectxtreme@gmail.com>
#
param ([switch]$WhatIf = $false, [switch]$Verbose = $false)
$groovydir = Split-Path -parent $MyInvocation.MyCommand.Path | Split-Path -parent
$libdir = Join-Path $groovydir "lib"
$orig_libdir = "$libdir.orig"
$indy_dir = Join-Path $groovydir "indy"
if (-not $(Test-Path $orig_libdir)) {
Move-Item -WhatIf:$WhatIf -Verbose:$Verbose $libdir $orig_libdir
}
else {
Remove-Item -WhatIf:$WhatIf -Verbose:$Verbose -Recurse -Force $libdir
}
$null = New-Item -ItemType Directory -WhatIf:$WhatIf -Verbose:$Verbose $libdir
foreach ($indy in Get-ChildItem "$indy_dir\*.jar") {
$t = $(Split-Path -leaf $indy) -replace "-indy.jar",".jar"
Copy-Item -WhatIf:$WhatIf -Verbose:$Verbose $indy $(Join-Path $libdir $t)
}
foreach ($orig in Get-ChildItem "$orig_libdir\*.jar") {
$dst = Join-Path $libdir $(Split-Path -leaf $orig)
if (Test-Path $dst) {
if ($Verbose) {
Write-Host -ForegroundColor yellow "Skip copying $orig"
}
}
else {
Copy-Item -WhatIf:$WhatIf -Verbose:$Verbose $orig $dst
}
}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment