grunt-closure-compiler icon indicating copy to clipboard operation
grunt-closure-compiler copied to clipboard

Made the java binary location customizable

Open gfreeau opened this issue 11 years ago • 5 comments

Closure compiler docs (https://code.google.com/p/closure-compiler/wiki/FAQ) recommend the use of 32bit JVM for performance improvements.

I was able to improve my project compile time from 70 seconds to 15 seconds by using their recommendations. The problem is the java binary is hard coded to use your system default.

This is not ideal because most people would be running a 64bit JVM and the 32bit JVM would only be used for a specific purpose, so trying to run a 32 bit JVM alongside a 64bit one would take a lot of tinkering.

With this patch you can specify this in the grunt task config:

{
    javaBin: '/opt/jdk1.8.0_20/bin/java -client -d32',
    closurePath: ...,
}

You can download any JDK and place it somewhere on the system and without setting any environment variables or editing anything etc, you can use it just for doing the compiling to gain the speed increase.

Also, is there any reason this.options() is not used in the task? Seems it would be more efficient for this.

gfreeau avatar Aug 19 '14 22:08 gfreeau

Looks great! Thanks a lot. Would you mind to add a quick documentation in the README.md file, just under the paragraph about closurePath?

Then I'll merge it.

gmarty avatar Aug 20 '14 09:08 gmarty

I made some docs for this setting.

Did you see my comment about this.options()? There are a few settings for this task that would benefit from being set globally:

i.e

grunt.initConfig({
  'closure-compiler': {
    options: {
      javaBin: '/opt/jdk1.8.0_20/bin/java -client -d32',
      closurePath: '/src/to/closure-compiler', 
    }
    frontend: {
      js: 'static/src/frontend.js',
      jsOutputFile: 'static/js/frontend.min.js',
      options: {
        compilation_level: 'ADVANCED',
      }
    }
  }
});

gfreeau avatar Aug 21 '14 01:08 gfreeau

Could someone tell me when this PR is going to be merged? As this would be a pretty helpful addition.

jarabek avatar Jan 08 '15 20:01 jarabek

+1

y-a-v-a avatar Jan 22 '15 11:01 y-a-v-a

Wow, this was so close to being merged...

tuckbick avatar Jun 01 '16 22:06 tuckbick