I have a java program that does some preparation and then invokes Jekyll on the content it's prepared. Jekyll is a Ruby program installed on the local PC as a gem. On windows and linux, no problem, but when running on OSX, under the eclipse debugger, Jekyll doesn't run. Presumably this is because of interactive shell issues (Jekyll runs fine from the terminal).
Here's my java code:
DefaultExecutor exec = new DefaultExecutor(); // from org.apache.commons.exec
exec.setExitValue(0);
MyFilterHandler pumpHandler = new MyFilterHandler();
exec.setWorkingDirectory(new File("/Users/grahamegrieve/temp/igs/swissnoso/temp/pages"));
ProcessBuilder processBuilder = new ProcessBuilder(new String("bash -c jekyll build --destination /Users/grahamegrieve/temp/igs/swissnoso/output"));
Map<String, String> env = processBuilder.environment();
Map<String, String> vars = new HashMap<>();
vars.putAll(env);
String path = "/Users/grahamegrieve/.gem/ruby/3.1.0/bin:/Users/grahamegrieve/.gem/ruby/3.1.0/bin:/opt/homebrew/opt/ruby/bin:/Users/grahamegrieve/.nvm/versions/node/v17.4.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:"+env.get("PATH");
vars.put("PATH", path);
exec.execute(org.apache.commons.exec.CommandLine.parse("bash -c -i jekyll build --destination /Users/grahamegrieve/temp/igs/swissnoso/output"), vars);
this results in the following output from the process:
A subcommand is required.
followed by Jekyll's standard documentation - so Jekyll is running but not getting the parameters. The same thing happens in terminal:
➜ ~ bash -c jekyll build --destination /Users/grahamegrieve/temp/igs/swissnoso/output
A subcommand is required.
jekyll 4.2.1 -- Jekyll is a blog-aware, static site generator in Ruby
Usage:
jekyll <subcommand> [options]
In the terminal, I can do this:
➜ ~ bash -c 'jekyll build --destination /Users/grahamegrieve/temp/igs/swissnoso/output'
Configuration file: none
Source: /Users/grahamegrieve
Destination: /Users/grahamegrieve/temp/igs/swissnoso/output
Incremental build: disabled. Enable with --incremental
Generating...
so the parameters work fine when the entire command is wrapped in ''. But putting '' (or "") in the java code results in
Jekyll: bash: jekyll build --destination /Users/grahamegrieve/temp/igs/swissnoso/output: No such file or directory
As far as I can tell, that means there is no file with the name 'Jekyll build ...'.
So I don't know how to invoke Jekyll from my java code on OSX. Is it possible?