Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Possible answer 1:</p> <p>The Google closure compiler does accept multiple input files with a syntax like this:</p> <pre><code>java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js </code></pre> <p>This will produce only one output file that is the combination of all of the inputs. But this might not be what you want if you're trying to compile each file separately.</p> <hr> <p>Possible answer 2:</p> <p>It would not be hard to write a small wrapper script (using <code>bash</code>, <code>python</code>, or your favorite scripting language) that accepts pairs of parameters, e.g.</p> <pre><code>wrapper.sh in1.js out1.js in2.js out2.js ... </code></pre> <p>The code in <code>wrapper.sh</code> could loop over the (pairs of) parameters and call <code>java -jar --js=xxx --js_output_file=yyy</code> repeatedly, waiting for each to complete before beginning the next. This would have the benefit of not starting each process in parallel, so at least you wouldn't have (potentially) many JVMs running at the same time. Though you do have some inefficiency in having to restart the JVM for each run.</p> <hr> <p>Possible answer 3:</p> <p>If you <em>really</em> want just one JVM, then there is no way to do what you ask without writing a little bit of Java code (as far as I know). If you are familiar with Java, you could copy the source code of <a href="http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/CommandLineRunner.java" rel="nofollow noreferrer">CommandLineRunner.java</a> and modify it to suit your needs.</p> <p>Or perhaps even easier, just write a small Java class whose <code>main</code> function simply invokes the <code>CommandLineRunner</code> main any number of times, passing in appropriate parameters to simulate a normal command line invocation. Here's something quick and dirty that would do the trick (<a href="https://stackoverflow.com/questions/309396/java-how-to-test-methods-that-call-system-exit">hat tip to VonC</a>)</p> <pre><code>import com.google.javascript.jscomp.CommandLineRunner; import java.security.Permission; public class MyRunner { public static void main(String [] args) { // Necessary since the closure compiler calls System.exit(...). System.setSecurityManager(new NoExitSecurityManager()); for (int i=0; i&lt;args.length; i+=2) { System.out.println("Compiling " + args[i] + " into " + args[i+1] + "..."); try { CommandLineRunner.main(new String[] { "--js=" + args[i], "--js_output_file=" + args[i+1] }); } catch (ExitException ee) { System.out.println("Finished with status: " + ee.getStatus()); } } } private static class ExitException extends SecurityException { private int status; public ExitException(int status) { this.status = status; } public int getStatus() { return status; } } private static class NoExitSecurityManager extends SecurityManager { public void checkPermission(Permission p) { } public void checkPermission(Permission p, Object context) { } public void checkExit(int status) { throw new ExitException(status); } } } </code></pre> <p>Compile it with with something like this:</p> <pre><code>javac -classpath compiler.jar MyRunner.java </code></pre> <p>Run it with something like this:</p> <pre><code>java -classpath .:compiler.jar MyRunner in1.js out1.js in2.js out2.js ... </code></pre> <p>And see output like this:</p> <pre><code>Compiling in1.js into out1.js... Finished with status: 0 Compiling in2.js into out2.js... Finished with status: 0 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload