wrap_groovyc.py 560 B

1234567891011121314151617181920212223
  1. import platform
  2. import sys
  3. import os
  4. import subprocess
  5. def fix_windows(args):
  6. for arg in args:
  7. if os.path.basename(arg) == 'groovyc' and os.path.basename(os.path.dirname(arg)) == 'bin':
  8. yield arg + '.bat'
  9. else:
  10. yield arg
  11. if __name__ == '__main__':
  12. env = os.environ.copy()
  13. jdk = sys.argv[1]
  14. env['JAVA_HOME'] = jdk
  15. args = sys.argv[2:]
  16. if platform.system() == 'Windows':
  17. sys.exit(subprocess.Popen(list(fix_windows(args)), env=env).wait())
  18. else:
  19. os.execve(args[0], args, env)