@@ -710,17 +710,6 @@ def closure_compiler(filename, pretty, advanced=True, extra_closure_args=None):
710
710
if extra_closure_args :
711
711
user_args += extra_closure_args
712
712
713
- # Closure compiler expects JAVA_HOME to be set *and* java.exe to be in the PATH in order
714
- # to enable use the java backend. Without this it will only try the native and JavaScript
715
- # versions of the compiler.
716
- java_bin = os .path .dirname (config .JAVA )
717
- if java_bin :
718
- def add_to_path (dirname ):
719
- env ['PATH' ] = env ['PATH' ] + os .pathsep + dirname
720
- add_to_path (java_bin )
721
- java_home = os .path .dirname (java_bin )
722
- env .setdefault ('JAVA_HOME' , java_home )
723
-
724
713
closure_cmd = get_closure_compiler ()
725
714
726
715
native_closure_compiler_works = check_closure_compiler (closure_cmd , user_args , env , allowed_to_fail = True )
@@ -729,6 +718,18 @@ def add_to_path(dirname):
729
718
user_args .append ('--platform=java' )
730
719
check_closure_compiler (closure_cmd , user_args , env , allowed_to_fail = False )
731
720
721
+ if config .JAVA and '--platform=java' in user_args :
722
+ # Closure compiler expects JAVA_HOME to be set *and* java.exe to be in the PATH in order
723
+ # to enable use the java backend. Without this it will only try the native and JavaScript
724
+ # versions of the compiler.
725
+ java_bin = os .path .dirname (config .JAVA )
726
+ if java_bin :
727
+ def add_to_path (dirname ):
728
+ env ['PATH' ] = env ['PATH' ] + os .pathsep + dirname
729
+ add_to_path (java_bin )
730
+ java_home = os .path .dirname (java_bin )
731
+ env .setdefault ('JAVA_HOME' , java_home )
732
+
732
733
# Closure externs file contains known symbols to be extern to the minification, Closure
733
734
# should not minify these symbol names.
734
735
CLOSURE_EXTERNS = [path_from_root ('src/closure-externs/closure-externs.js' )]
0 commit comments