Repository: google/closure-compiler
Issue: File order not maintained

I call the closure compiler like:

```
java.exe -jar dev\\jars\\closure\\compiler.jar --compilation_level WHITESPACE_ONLY --formatting PRETTY_PRINT --formatting PRINT_INPUT_DELIMITER --formatting SINGLE_QUOTES --js_output_file jQuery_a52d83c3.min.js --js jquery.js ui\\core.js ui\\widget.js ui\\mouse.js ui\\draggable.js ui\\droppable.js ui\\resizable.js ui\\selectable.js ui\\sortable.js ui\\button.js ui\\position.js
```

When I use the `compiler.jar` from github binary downloads `compiler-20151216.tar.gz` everything is fine. When I use `compiler-20160208.tar.gz` the file originial order is not maintained in the compressed file which breaks the code, as the js files have to be included in a specific order.
I tried the new parameter `--dependency_mode NONE` but it changed nothing. According to the docs should NONE be the default.

I'm on Windows 10, 64 bit JAVA 8 as provided by Oracle.


Changed files:
src/com/google/javascript/jscomp/CommandLineRunner.java, test/com/google/javascript/jscomp/CommandLineRunnerTest.java

diff --git a/src/com/google/javascript/jscomp/CommandLineRunner.java b/src/com/google/javascript/jscomp/CommandLineRunner.java
index 65e615bdd..cd1896c4a 100644
--- a/src/com/google/javascript/jscomp/CommandLineRunner.java
+++ b/src/com/google/javascript/jscomp/CommandLineRunner.java
@@ -62,6 +62,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -757,7 +758,7 @@ public class CommandLineRunner extends
             mixedSources.remove(new FlagEntry<>(JsSourceType.JS, filename));
           }
         } else {
-          for (String filename : findJsFiles(Collections.singletonList(source.value))) {
+          for (String filename : findJsFiles(Collections.singletonList(source.value), true)) {
             if (!excludes.contains(filename)) {
               mixedSources.add(new FlagEntry<>(JsSourceType.JS, filename));
             }
@@ -1503,7 +1504,20 @@ public class CommandLineRunner extends
    * within the directory and sub-directories.
    */
   public static List<String> findJsFiles(Collection<String> patterns) throws IOException {
-    Set<String> allJsInputs = new TreeSet<>();
+    return findJsFiles(patterns, false);
+  }
+
+  /**
+   * Returns all the JavaScript files from the set of patterns.
+   *
+   * @param patterns A collection of filename patterns.
+   * @param sortAlphabetically Whether the output filenames should be in alphabetical order.
+   * @return The list of JS filenames found by expanding the patterns.
+   */
+  private static List<String> findJsFiles(Collection<String> patterns, boolean sortAlphabetically)
+      throws IOException {
+    Set<String> allJsInputs = sortAlphabetically
+        ? new TreeSet<String>() : new LinkedHashSet<String>();
     Set<String> excludes = new HashSet<>();
     for (String pattern : patterns) {
       if (!pattern.contains("*") && !pattern.startsWith("!")) {
diff --git a/test/com/google/javascript/jscomp/CommandLineRunnerTest.java b/test/com/google/javascript/jscomp/CommandLineRunnerTest.java
index 114df7d5e..e270af668 100644
--- a/test/com/google/javascript/jscomp/CommandLineRunnerTest.java
+++ b/test/com/google/javascript/jscomp/CommandLineRunnerTest.java
@@ -1094,9 +1094,11 @@ public final class CommandLineRunnerTest extends TestCase {
   }
 
   public void testInputMultipleJsFilesWithOneJsFlag() throws IOException, FlagUsageException {
+    // Test that file order is preserved with --js test3.js test2.js test1.js
     FlagEntry<JsSourceType> jsFile1 = createJsFile("test1", "var a;");
     FlagEntry<JsSourceType> jsFile2 = createJsFile("test2", "var b;");
-    compileJsFiles("var a;var b;", jsFile1, jsFile2);
+    FlagEntry<JsSourceType> jsFile3 = createJsFile("test3", "var c;");
+    compileJsFiles("var c;var b;var a;", jsFile3, jsFile2, jsFile1);
   }
 
   public void testGlobJs1() throws IOException, FlagUsageException {