Move over to bazel-integration-testing for the integration test framework

Change-Id: Ie403a32851fba45ffc64826cf7ac94e990e49999
diff --git a/.classpath b/.classpath
index 163f5ec..0d26dc0 100644
--- a/.classpath
+++ b/.classpath
@@ -9,5 +9,6 @@
 	<classpathentry kind="lib" path="runfiles/com_google_truth/jar/truth-0.31.jar"/>
 	<classpathentry kind="lib" path="runfiles/org_junit/jar/junit-4.11.jar"/>
 	<classpathentry kind="lib" path="runfiles/org_hamcrest_core/jar/hamcrest-core-1.3.jar"/>
+	<classpathentry kind="lib" path="runfiles/build_bazel_integration_testing/java/build/bazel/tests/integration/libintegration.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/WORKSPACE b/WORKSPACE
index 87c8078..0251b7c 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,11 +1,19 @@
 workspace(name = "build_bazel_eclipse")
 
-load("//tools/build_defs:eclipse.bzl", "load_eclipse_deps")
-load("//:bazel_version.bzl", "check_bazel_version")
-load("//tools/build_defs:bazel_integration_test.bzl", "bazel_binaries")
-check_bazel_version("0.5.0")
-bazel_binaries()
+# TODO(dmarting): switch to release version of integration testing
+http_archive(
+    name = "build_bazel_integration_testing",
+    url = "https://github.com/bazelbuild/bazel-integration-testing/archive/55a6a70dbcc2cc7699ee715746fb1452788f8d3c.zip",
+    sha256 = "b505866c12b9f6ce08b96a16305407deae43bef7655a8e7c2197d08c24c6cb04",
+    strip_prefix = "bazel-integration-testing-55a6a70dbcc2cc7699ee715746fb1452788f8d3c",
+)
 
+load("@build_bazel_integration_testing//:bazel_version.bzl", "check_bazel_version")
+load("@build_bazel_integration_testing//tools:bazel_java_integration_test.bzl", "bazel_java_integration_test_deps")
+check_bazel_version("0.5.0")
+bazel_java_integration_test_deps()
+
+load("//tools/build_defs:eclipse.bzl", "load_eclipse_deps")
 load_eclipse_deps()
 
 new_http_archive(
@@ -27,26 +35,11 @@
 
 # TODO(dmarting): Use http_file and relies on a mirror instead of maven_jar
 maven_jar(
-    name = "com_google_guava",
-    artifact = "com.google.guava:guava:jar:21.0",
-)
-
-maven_jar(
     name = "org_json",
     artifact = "org.json:json:jar:20160212",
 )
 
 maven_jar(
-    name = "org_hamcrest_core",
-    artifact = "org.hamcrest:hamcrest-core:jar:1.3",
-)
-
-maven_jar(
-    name = "org_junit",
-    artifact = "junit:junit:jar:4.11",
-)
-
-maven_jar(
     name = "com_google_truth",
     artifact = "com.google.truth:truth:jar:0.31",
 )
diff --git a/bazel_version.bzl b/bazel_version.bzl
deleted file mode 100644
index 9d78389..0000000
--- a/bazel_version.bzl
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copied from https://github.com/tensorflow/tensorflow/blob/dfa7d2d2953c3d33d2e8deb898240be008de5be6/tensorflow/workspace.bzl
-
-# Parse the bazel version string from `native.bazel_version`.
-def _parse_bazel_version(bazel_version):
-  # Remove commit from version.
-  version = bazel_version.split(" ", 1)[0]
-
-  # Split into (release, date) parts and only return the release
-  # as a tuple of integers.
-  parts = version.split('-', 1)
-
-  # Turn "release" into a tuple of strings
-  version_tuple = ()
-  for number in parts[0].split('.'):
-    version_tuple += (str(number),)
-  return version_tuple
-
-# Check that a specific bazel version is being used.
-def check_bazel_version(bazel_version):
-  if "bazel_version" not in dir(native):
-    fail("\nCurrent Bazel version is lower than 0.2.1, expected at least %s\n" % bazel_version)
-  elif not native.bazel_version:
-    print("\nCurrent Bazel is not a release version, cannot check for compatibility.")
-    print("Make sure that you are running at least Bazel %s.\n" % bazel_version)
-  else:
-    current_bazel_version = _parse_bazel_version(native.bazel_version)
-    minimum_bazel_version = _parse_bazel_version(bazel_version)
-    if minimum_bazel_version > current_bazel_version:
-      fail("\nCurrent Bazel version is {}, expected at least {}\n".format(
-          native.bazel_version, bazel_version))
-  pass
diff --git a/javatests/com/google/devtools/bazel/e4b/integration/AspectIntegrationTest.java b/javatests/com/google/devtools/bazel/e4b/integration/AspectIntegrationTest.java
index 505f046..08855a3 100644
--- a/javatests/com/google/devtools/bazel/e4b/integration/AspectIntegrationTest.java
+++ b/javatests/com/google/devtools/bazel/e4b/integration/AspectIntegrationTest.java
@@ -22,9 +22,11 @@
 import org.junit.Before;
 import org.junit.Test;
 
+import build.bazel.tests.integration.Command;
+import build.bazel.tests.integration.BazelBaseTestCase;
+
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
-import com.google.devtools.bazel.e4b.command.Command;
 import com.google.devtools.bazel.e4b.command.IdeBuildInfo;
 
 /** Integration test for the aspect used by the plugin. */
@@ -97,9 +99,9 @@
         "--output_groups=ide-info-text,ide-resolve,-_,-defaults", "--experimental_show_artifacts",
         "//...");
     int retCode = cmd.run();
-    assertEquals("Bazel failed to build, stderr: " + LINE_JOINER.join(cmd.getSelectedErrorLines()),
+    assertEquals("Bazel failed to build, stderr: " + LINE_JOINER.join(cmd.getErrorLines()),
         0, retCode);
-    String[] jsonFiles = cmd.getSelectedErrorLines().stream().filter((s) -> {
+    String[] jsonFiles = cmd.getErrorLines().stream().filter((s) -> {
       return s.startsWith(">>>") && s.endsWith(".json");
     }).map((s) -> {
       return s.substring(3);
diff --git a/javatests/com/google/devtools/bazel/e4b/integration/BUILD b/javatests/com/google/devtools/bazel/e4b/integration/BUILD
index 1c15c75..ead98ca 100644
--- a/javatests/com/google/devtools/bazel/e4b/integration/BUILD
+++ b/javatests/com/google/devtools/bazel/e4b/integration/BUILD
@@ -1,45 +1,12 @@
-load("//tools/build_defs:bazel_integration_test.bzl", "BAZEL_VERSIONS")
+load("@build_bazel_integration_testing//tools:bazel_java_integration_test.bzl", "bazel_java_integration_test")
 
-java_library(
-    name = "base",
-    srcs = ["BazelBaseTestCase.java"],
-    data = [
-        "@build_bazel_bazel_%s//:bazel_binary" % v.replace(".", "_")
-        for v in BAZEL_VERSIONS
-    ],
+bazel_java_integration_test(
+    name = "AspectIntegrationTest",
+    srcs = ["AspectIntegrationTest.java"],
+    data = ["//resources:srcs"],
     deps = [
         "//java/com/google/devtools/bazel/e4b/command",
         "@com_google_guava//jar",
-        "@org_junit//jar",
+        "@com_google_truth//jar",
     ],
 )
-
-[java_test(
-    name = "base_integration_test_with_bazel_" + version,
-    srcs = ["BazelBaseTestCaseTest.java"],
-    test_class = "com.google.devtools.bazel.e4b.integration.BazelBaseTestCaseTest",
-    jvm_flags = ["-Dbazel.version=" + version],
-    deps = [
-        ":base",
-        "//java/com/google/devtools/bazel/e4b/command",
-        "@com_google_truth//jar",
-        "@org_hamcrest_core//jar",
-        "@org_junit//jar",
-    ],
-)for version in BAZEL_VERSIONS]
-
-[java_test(
-    name = "aspect_integration_test_with_bazel_" + version,
-    srcs = ["AspectIntegrationTest.java"],
-    test_class = "com.google.devtools.bazel.e4b.integration.AspectIntegrationTest",
-    data = ["//resources:srcs"],
-    jvm_flags = ["-Dbazel.version=" + version],
-    deps = [
-        ":base",
-        "//java/com/google/devtools/bazel/e4b/command",
-        "@com_google_guava//jar",
-        "@com_google_truth//jar",
-        "@org_hamcrest_core//jar",
-        "@org_junit//jar",
-    ],
-) for version in BAZEL_VERSIONS]
diff --git a/javatests/com/google/devtools/bazel/e4b/integration/BazelBaseTestCase.java b/javatests/com/google/devtools/bazel/e4b/integration/BazelBaseTestCase.java
deleted file mode 100644
index 1ed8838..0000000
--- a/javatests/com/google/devtools/bazel/e4b/integration/BazelBaseTestCase.java
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.bazel.e4b.integration;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-import com.google.devtools.bazel.e4b.command.Command;
-
-/** A base class to do integration test that call Bazel */
-public abstract class BazelBaseTestCase {
-
-  protected final static Joiner PATH_JOINER = Joiner.on(File.separator);
-  protected final static Joiner LINE_JOINER = Joiner.on("\n");
-
-  private static File tmp;
-  private static Map<String, File> bazelVersions;
-  private static File runfileDirectory = new File(System.getenv("TEST_SRCDIR"));
-
-  private File currentBazel = null;
-
-  /** The current workspace. */
-  protected File workspace = null;
-
-  public static class BazelTestCaseException extends Exception {
-    private static final long serialVersionUID = 1L;
-
-    private BazelTestCaseException(String message) {
-      super(message);
-    }
-  }
-
-  @BeforeClass
-  public static void setUpClass() throws IOException {
-    // Get tempdir
-    String _tmp = System.getenv("TEST_TMPDIR");
-    if (_tmp == null) {
-      File p = Files.createTempDirectory("e4b-tests").toFile();
-      p.deleteOnExit();
-      tmp = p;
-    } else {
-      tmp = new File(_tmp);
-    }
-    bazelVersions = new HashMap<>();
-  }
-
-  /** Return a file in the runfiles whose path segments are given by the arguments. */
-  protected static File getRunfile(String... segments) {
-    return new File(PATH_JOINER.join(runfileDirectory, PATH_JOINER.join(segments)));
-  }
-
-  private static void unpackBazel(String version)
-      throws BazelTestCaseException, IOException, InterruptedException {
-    if (!bazelVersions.containsKey(version)) {
-      // Get bazel location
-      File bazelFile = getRunfile("build_bazel_bazel_" + version.replace('.', '_') + "/bazel");
-      if (!bazelFile.exists()) {
-        throw new BazelTestCaseException(
-            "Bazel version " + version + " not found");
-      }
-      bazelVersions.put(version, bazelFile);
-      // Unzip Bazel
-      prepareCommand(tmp,
-          ImmutableList.of(bazelVersions.get(version).getCanonicalPath(),
-              "--output_user_root=" + tmp,
-          "--nomaster_bazelrc",
-              "--max_idle_secs=30", "--bazelrc=/dev/null", "help")).run();
-    }
-  }
-
-  /** Specify with bazel version to use, required before calling bazel. */
-  protected void bazelVersion(String version)
-      throws BazelTestCaseException, IOException, InterruptedException {
-    unpackBazel(version);
-    currentBazel = bazelVersions.get(version);
-  }
-
-  /** Create a new workspace, previous one can still be used. */
-  protected void newWorkspace() throws IOException {
-    this.workspace = java.nio.file.Files.createTempDirectory(tmp.toPath(), "workspace").toFile();
-    this.scratchFile("WORKSPACE");
-  }
-
-  @Before
-  public void setUp() throws Exception {
-    this.currentBazel = null;
-    if (System.getProperty("bazel.version") != null) {
-      bazelVersion(System.getProperty("bazel.version"));
-    }
-    newWorkspace();
-  }
-
-  /** Prepare bazel for running, and return the {@link Command} object to run it. */
-  protected Command bazel(String... args) throws BazelTestCaseException, IOException {
-    return bazel(ImmutableList.copyOf(args));
-  }
-
-  /** Prepare bazel for running, and return the {@link Command} object to run it. */
-  protected Command bazel(Iterable<String> args) throws BazelTestCaseException, IOException {
-    if (currentBazel == null) {
-      throw new BazelTestCaseException("Cannot use bazel because no version was specified, "
-          + "please call bazelVersion(version) before calling bazel(...).");
-    }
-
-    return prepareCommand(workspace,
-        ImmutableList.<String>builder()
-            .add(currentBazel.getCanonicalPath(), "--output_user_root=" + tmp, "--nomaster_bazelrc",
-                "--max_idle_secs=10", "--bazelrc=/dev/null")
-            .addAll(args).build());
-  }
-
-  /**
-   * Copy a file from the runfiles under {@code path} into {@code destpath} under the current
-   * workspace.
-   */
-  protected void copyFromRunfiles(String path, String destpath) throws IOException {
-    File origin = getRunfile(path);
-    File dest = new File(workspace, destpath);
-    if (!dest.getParentFile().exists()) {
-      dest.getParentFile().mkdirs();
-    }
-    Files.copy(origin.toPath(), dest.toPath());
-  }
-
-  /**
-   * Copy a file from the runfiles under {@code path} into {@code path} under the current workspace.
-   */
-  protected void copyFromRunfiles(String path) throws IOException {
-    copyFromRunfiles(path, path);
-  }
-
-  /**
-   * Create a file under {@code path} in the current workspace, filling it with the lines given in
-   * {@code content}.
-   */
-  protected void scratchFile(String path, String... content) throws IOException {
-    File dest = new File(workspace,path);
-    if (!dest.getParentFile().exists()) {
-      dest.getParentFile().mkdirs();
-    }
-    Files.write(dest.toPath(), LINE_JOINER.join(content).getBytes(StandardCharsets.UTF_8));
-  }
-
-  private static Command prepareCommand(File folder, Iterable<String> command) throws IOException {
-    Command.Builder builder = Command.builder(null).setConsoleName(null).setDirectory(folder);
-    builder.addArguments(command);
-    builder.setStderrLineSelector((String x) -> {
-      return x;
-    }).setStdoutLineSelector((String x) -> {
-      return x;
-    });
-    return builder.build();
-  }
-}
diff --git a/javatests/com/google/devtools/bazel/e4b/integration/BazelBaseTestCaseTest.java b/javatests/com/google/devtools/bazel/e4b/integration/BazelBaseTestCaseTest.java
deleted file mode 100644
index c7be128..0000000
--- a/javatests/com/google/devtools/bazel/e4b/integration/BazelBaseTestCaseTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.devtools.bazel.e4b.integration;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-import com.google.devtools.bazel.e4b.command.Command;
-
-/** {@link BazelBaseTestCase}Test */
-public final class BazelBaseTestCaseTest extends BazelBaseTestCase {
-
-  @Test
-  public void testVersion() throws Exception {
-    Command cmd = bazel("info", "release");
-    assertEquals(0, cmd.run());
-    assertThat(cmd.getSelectedOutputLines())
-        .contains("release " + System.getProperty("bazel.version"));
-  }
-}
diff --git a/runfiles b/runfiles
index 3ad15da..859b3f5 120000
--- a/runfiles
+++ b/runfiles
@@ -1 +1 @@
-bazel-bin/javatests/com/google/devtools/bazel/e4b/command/CommandTest.runfiles
\ No newline at end of file
+bazel-bin/javatests/com/google/devtools/bazel/e4b/integration/AspectIntegrationTest/bazel0.5.0.runfiles
\ No newline at end of file
diff --git a/tools/build_defs/BUILD b/tools/build_defs/BUILD
index 673e8ba..00dc44c 100644
--- a/tools/build_defs/BUILD
+++ b/tools/build_defs/BUILD
@@ -1,12 +1,6 @@
 package(default_visibility = ["//visibility:public"])
 
 py_binary(
-    name = "create_bazel_hashdict",
-    srcs = ["create_bazel_hashdict.py"],
-    deps = ["@com_google_python_gflags//:gflags"],
-)
-
-py_binary(
     name = "feature_builder",
     srcs = ["feature_builder.py"],
     deps = ["@com_google_python_gflags//:gflags"],
diff --git a/tools/build_defs/bazel_hash_dict.bzl b/tools/build_defs/bazel_hash_dict.bzl
deleted file mode 100644
index 40b16e0..0000000
--- a/tools/build_defs/bazel_hash_dict.bzl
+++ /dev/null
@@ -1,20 +0,0 @@
-# Automatically generated by create_hash_dict '--output=tools/build_defs/bazel_hash_dict.bzl'
-
-BAZEL_HASH_DICT = {
-    '0.5.0': {
-        'darwin-x86_64': '5ccdb953dc2b8d81f15ea185f47ecfc7ddc39ad0c6f71e561ec7398377c8cc1a',
-        'linux-x86_64': 'd026e581a860f305791f3ba839462ff02b1929858b37d1db2f27af212be73741',
-    },
-    '0.5.1': {
-        'darwin-x86_64': '8d92a67a204abdd84376a4265d372e4a9bfc31872e825c028ce261d20bad352a',
-        'linux-x86_64': '27bc739082a241e2f7f1a89fbaea3306e3edc40d930472c6789d49dc17fde3d2',
-    },
-    '0.5.2': {
-        'darwin-x86_64': '31b92de24cd251923b09773c4c20bcf2014390d930c6a3b7f043558975743510',
-        'linux-x86_64': '9a1b6fff69ba8aff460bd1883dd51702b7ad0e4c979c5dcab75baf65027684ef',
-    },
-    '0.5.3': {
-        'darwin-x86_64': '4bbcf198c9daeab8597f748aead68e10bcb3ce720fb8e3d474b2e72825c23fb0',
-        'linux-x86_64': '7545e5164450c8777aca07903328c9744f930bcba51f2a10fe54f3d1ece49097',
-    },
-}
diff --git a/tools/build_defs/bazel_integration_test.bzl b/tools/build_defs/bazel_integration_test.bzl
deleted file mode 100644
index 5b0b3ae..0000000
--- a/tools/build_defs/bazel_integration_test.bzl
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# My custom made integration test framework for using Bazel
-load(":bazel_hash_dict.bzl", "BAZEL_HASH_DICT")
-
-BAZEL_VERSIONS = BAZEL_HASH_DICT.keys()
-
-_BAZEL_BINARY_PACKAGE = "http://releases.bazel.build/{version}/release/bazel-{version}-without-jdk-installer-{platform}.sh"
-
-def _get_platform_name(rctx):
-  os_name = rctx.os.name.lower()
-  # We default on linux-x86_64 because we only support 2 platforms
-  return "darwin-x86_64" if os_name.startswith("mac os") else "linux-x86_64"
-
-def _get_installer(rctx):
-  platform = _get_platform_name(rctx)
-  version = rctx.attr.version
-  url = _BAZEL_BINARY_PACKAGE.format(version=version, platform=platform)
-  args = {"url": url, "type": "zip", "output": "bin"}
-  if version in BAZEL_HASH_DICT and platform in BAZEL_HASH_DICT[version]:
-    args["sha256"] = BAZEL_HASH_DICT[version][platform]
-  rctx.download_and_extract(**args)
-
-def _bazel_repository_impl(rctx):
-  _get_installer(rctx)
-  rctx.file("WORKSPACE", "workspace(name='%s')" % rctx.attr.name)
-  rctx.file("BUILD", """
-genrule(
-  name = "bazel_binary",
-  outs = ["bazel"],
-  srcs = ["bin/bazel-real"],
-  cmd = "cp $< $@",
-  output_to_bindir = True,
-  visibility = ["//visibility:public"])""")
-
-bazel_binary = repository_rule(
-  implementation=_bazel_repository_impl,
-  attrs = {"version": attr.string(default = "0.5.3")})
-
-def bazel_binaries(versions = BAZEL_VERSIONS):
-  for version in versions:
-    bazel_binary(
-      name = "build_bazel_bazel_" + version.replace(".", "_"),
-      version = version)
diff --git a/tools/build_defs/create_bazel_hashdict.py b/tools/build_defs/create_bazel_hashdict.py
deleted file mode 100644
index f5a2ff2..0000000
--- a/tools/build_defs/create_bazel_hashdict.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# Copyright 2017 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""Generate a Skylark file containing a map of hash of bazel installers."""
-
-import gflags
-import urllib2
-import sys
-
-_URL_FORMAT = "http://releases.bazel.build/{version}/release/bazel-{version}-without-jdk-installer-{platform}.sh.sha256"
-_URL_EXISTS = "http://releases.bazel.build/{version}/release/index.html"
-
-gflags.DEFINE_string("output", "bazel_hash_dict.bzl", "The output file")
-
-gflags.DEFINE_string("map_name", "BAZEL_HASH_DICT",
-                     "The name of the generated map in the output file")
-
-gflags.DEFINE_multistring("platforms", ["darwin-x86_64", "linux-x86_64"],
-                          "List of platforms to download SHA-256.")
-
-gflags.DEFINE_string("minimum_version", "0.5.0",
-                     "The lowest version of Bazel supported")
-
-FLAGS = gflags.FLAGS
-
-
-def get_hash_map(f):
-    """Construct the hash map reading the release website, writing it to f."""
-    splitted_version = FLAGS.minimum_version.split(".")
-    if len(splitted_version) != 3:
-        sys.stderr.write(("Invalid version '%s', "
-                          "expected a dot-separated version with 3 components "
-                          "(e.g. 3.1.2)") % FLAGS.minimum_version)
-        sys.exit(-1)
-    version = [
-        int(splitted_version[0]),
-        int(splitted_version[1]),
-        int(splitted_version[2])
-    ]
-    while True:
-        try:
-            v = "%s.%s.%s" % (version[0], version[1], version[2])
-            print "Getting SHA-256 for version " + v
-            # Force 404 before we actually add the information
-            urllib2.urlopen(_URL_EXISTS.format(version=v)).read()
-            f.write("    '%s': {\n" % v)
-            for platform in FLAGS.platforms:
-                r = urllib2.urlopen(
-                    _URL_FORMAT.format(version=v, platform=platform))
-                f.write("        '%s': '%s',\n" % (platform,
-                                                   r.read().split(" ", 1)[0]))
-            f.write("    },\n")
-            version[2] += 1
-        except urllib2.HTTPError as e:
-            if e.code == 404:
-                print "  ==> Not a Bazel version"
-                # Current version does not exists, increase the lowest non null version number
-                if version[2] == 0:
-                    if version[1] == 0:
-                        return
-                    version[1] = 0
-                    version[0] += 1
-                else:
-                    version[2] = 0
-                    version[1] += 1
-            else:
-                raise e
-
-
-def print_command_line(f):
-    """Print the current command line."""
-    f.write("create_hash_dict")
-    for i in range(1, len(sys.argv)):
-        f.write(" '%s'" % (sys.argv[i].replace("'", "'\\''")))
-
-
-def main(unused_argv):
-    with open(FLAGS.output, "w") as f:
-        f.write("# Automatically generated by ")
-        print_command_line(f)
-        f.write("\n\n%s = {\n" % FLAGS.map_name)
-        get_hash_map(f)
-        f.write("}\n")
-
-
-if __name__ == "__main__":
-    main(FLAGS(sys.argv))