Question

I am using grunt-jsdoc to manage the execution of jsdoc command, which depends on Java and needs to have the JAVA_HOME environment variable set. Assuming they already have node.js and Java, I'm trying to limit the local developer setup (on either Linux or Windows) to:

  1. Checkout the project
  2. run npm install

I have this working on Linux by using the grunt-shell plugin and running a task like this right before the jsdoc task:

// left out the part where I don't execute this task if JAVA_HOME already set
shell: {
  getjavahome_linux: {
    command: 'readlink -f /usr/bin/java | sed "s:bin/java::"',
    options: {
      callback: function(err, stdout, stderr, cb) { 
        process.env.JAVA_HOME = stdout; 
        cb(); 
      }
    }
  }
}

But I have not been able to find a similar command for Windows, to say nothing of other platforms. My question:

A) Is there a better approach in Grunt that does not require these platform-specific commands?

OR

B) If not, anyone have a Windows command that will do the equivalent of the Linux version above?

Note: actually setting JAVA_HOME inside the shell command does not work with grunt-jsdoc, but getting the output and setting process.env.JAVA_HOME works great.

Was it helpful?

Solution

The JAVA_HOME env var check becomes a simple warning since version 0.3.3 of grunt-jsdoc

And since version 0.5.0, it doesn't require the Java version of jdsoc anymore. It fully runs on node.js

OTHER TIPS

On windows, I use cygwin shell (the git-bash version) to run Grunt where JAVA_HOME is set...

But it should work from the windows cmd, I've juste tried:

test.js

console.log(process.env.JAVA_HOME);

cmd.exe

set JAVA_HOME=D:\path
node test.js

displays the path

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top