Skip to content

Made the java binary location customizable #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,30 @@ You can specify the path and name where the report will be saved using the `repo

To deactivate report creation, set `noreport` to `true`.

### `javaBin` property

The default JVM on your system will be used to run the closure compiler. For most users, this will be a 64-bit JVM. The closure compiler is much faster when run with a 32bit JVM and in client mode. You can read more about this at the [closure compiler FAQ](https://code.google.com/p/closure-compiler/wiki/FAQ).

Rather than deal with the hassle of trying to run multiple versions of the JVM it is simpler to download it to a directory and without modifying any environment variables, call the java binary using an absolute path.

You can download a 32bit version of java from here: http://www.oracle.com/technetwork/java/javase/downloads/index.html. As an example, download the Java SE 8 JDK, extract the contents and move the directory to the desired location such as `/opt` in a linux environment. You will end up with a path such as `/opt/jdk1.8.0_20`.

You can then use the javaBin property to specify a custom java binary command such as:

```javascript
grunt.initConfig({
'closure-compiler': {
frontend: {
javaBin: '/opt/jdk1.8.0_20/bin/java -client -d32',
js: 'static/src/frontend.js',
jsOutputFile: 'static/js/frontend.min.js',
}
}
})
```

It is not unusual to gain an order of magnitude gain in performance when compiling many files in this way.

### `js` property

This task is a [multi task](https://github.com/cowboy/grunt/blob/master/docs/types_of_tasks.md), you can specify several targets. The task can minify many scripts at a time.
Expand Down
3 changes: 2 additions & 1 deletion tasks/closure-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ module.exports = function(grunt) {
return false;
}

var command = 'java -jar "' + closurePath + '/build/compiler.jar"';
var javaBin = data.javaBin || 'java';
var command = javaBin + ' -jar "' + closurePath + '/build/compiler.jar"';

data.cwd = data.cwd || './';

Expand Down