aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/wrap_groovyc.py
blob: 068b73fd87a04fd8b790e5efabfd1eba2911d4bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import platform
import sys
import os
import subprocess


def fix_windows(args):
    for arg in args:
        if os.path.basename(arg) == 'groovyc' and os.path.basename(os.path.dirname(arg)) == 'bin':
            yield arg + '.bat'
        else:
            yield arg


if __name__ == '__main__':
    env = os.environ.copy()
    jdk = sys.argv[1]
    env['JAVA_HOME'] = jdk
    args = sys.argv[2:]
    if platform.system() == 'Windows':
        sys.exit(subprocess.Popen(list(fix_windows(args)), env=env).wait())
    else:
        os.execve(args[0], args, env)