Bazel: Automatically fix lint errors with buildifier

In recent buildifier versions, lint errors can be fixed automatically:

  $ find . \( -name BUILD -o -name "*.bzl" \) -print \
      | xargs buildifier --lint=fix

This commit was created with Buildifier version 0.19.2:

  $ buildifier --version
buildifier version: 0.19.2
buildifier scm revision: d39e4d5c25111527369142f16cdb49aa67707313

Change-Id: I1f06cd4596e794981ccc2d9fc2d1da9b17f3973a
diff --git a/tools/bzl/asciidoc.bzl b/tools/bzl/asciidoc.bzl
index ab452c5..6177472 100644
--- a/tools/bzl/asciidoc.bzl
+++ b/tools/bzl/asciidoc.bzl
@@ -46,7 +46,7 @@
         cmd.append("--searchbox")
     else:
         cmd.append("--no-searchbox")
-    ctx.action(
+    ctx.actions.run_shell(
         inputs = [ctx.file._exe, ctx.file.src],
         outputs = [ctx.outputs.out],
         command = cmd,
@@ -114,7 +114,7 @@
         ".html",
     ]
     args.extend(_generate_asciidoc_args(ctx))
-    ctx.action(
+    ctx.actions.run(
         inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version],
         outputs = ctx.outputs.outs,
         executable = ctx.executable._exe,
@@ -221,7 +221,7 @@
         ".html",
     ]
     args.extend(_generate_asciidoc_args(ctx))
-    ctx.action(
+    ctx.actions.run(
         inputs = ctx.files.srcs + [ctx.executable._exe, ctx.file.version],
         outputs = [ctx.outputs.out],
         executable = ctx.executable._exe,
@@ -279,7 +279,7 @@
         "cd %s" % tmpdir,
         "zip -qr $p/%s *" % ctx.outputs.out.path,
     ])
-    ctx.action(
+    ctx.actions.run_shell(
         inputs = [ctx.file.src] + ctx.files.resources,
         outputs = [ctx.outputs.out],
         command = " && ".join(cmd),
diff --git a/tools/bzl/classpath.bzl b/tools/bzl/classpath.bzl
index afdd907..9ec5f15 100644
--- a/tools/bzl/classpath.bzl
+++ b/tools/bzl/classpath.bzl
@@ -7,8 +7,8 @@
         elif hasattr(d, "files"):
             all += d.files
 
-    as_strs = [c.path for c in all]
-    ctx.file_action(
+    as_strs = [c.path for c in all.to_list()]
+    ctx.actions.write(
         output = ctx.outputs.runtime,
         content = "\n".join(sorted(as_strs)),
     )
diff --git a/tools/bzl/gwt.bzl b/tools/bzl/gwt.bzl
index c51e914..a0500bd 100644
--- a/tools/bzl/gwt.bzl
+++ b/tools/bzl/gwt.bzl
@@ -117,14 +117,14 @@
         impl = ALIASES[ua]
 
     # intermediate artifact: user agent speific GWT xml file
-    gwt_user_agent_xml = ctx.new_file(ctx.label.name + "_gwt.xml")
-    ctx.file_action(
+    gwt_user_agent_xml = ctx.actions.declare_file(ctx.label.name + "_gwt.xml")
+    ctx.actions.write(
         output = gwt_user_agent_xml,
         content = USER_AGENT_XML % (MODULE, impl),
     )
 
     # intermediate artifact: user agent specific zip with GWT module
-    gwt_user_agent_zip = ctx.new_file(ctx.label.name + "_gwt.zip")
+    gwt_user_agent_zip = ctx.actions.declare_file(ctx.label.name + "_gwt.zip")
     gwt = "%s_%s.gwt.xml" % (MODULE.replace(".", "/"), ua)
     dir = gwt_user_agent_zip.path + ".dir"
     cmd = " && ".join([
@@ -135,7 +135,7 @@
         "cp $p/%s %s" % (gwt_user_agent_xml.path, gwt),
         "$p/%s cC $p/%s $(find . | sed 's|^./||')" % (ctx.executable._zip.path, gwt_user_agent_zip.path),
     ])
-    ctx.action(
+    ctx.actions.run_shell(
         inputs = [gwt_user_agent_xml] + ctx.files._zip,
         outputs = [gwt_user_agent_zip],
         command = cmd,
@@ -190,7 +190,7 @@
         ),
     ])
 
-    ctx.action(
+    ctx.actions.run_shell(
         inputs = list(deps) + ctx.files._jdk + ctx.files._zip + gwt_user_agent_modules,
         outputs = [output_zip],
         mnemonic = "GwtBinary",
diff --git a/tools/bzl/javadoc.bzl b/tools/bzl/javadoc.bzl
index e17a031..b304db9 100644
--- a/tools/bzl/javadoc.bzl
+++ b/tools/bzl/javadoc.bzl
@@ -23,7 +23,7 @@
         source_jars += l.java.source_jars
         transitive_jar_set += l.java.transitive_deps
 
-    transitive_jar_paths = [j.path for j in transitive_jar_set]
+    transitive_jar_paths = [j.path for j in transitive_jar_set.to_list()]
     dir = ctx.outputs.zip.path + ".dir"
     source = ctx.outputs.zip.path + ".source"
     external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs
@@ -32,7 +32,7 @@
         "export TZ",
         "rm -rf %s" % source,
         "mkdir %s" % source,
-        " && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]),
+        " && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars.to_list()]),
         "rm -rf %s" % dir,
         "mkdir %s" % dir,
         " ".join([
@@ -55,8 +55,8 @@
         "find %s -exec touch -t 198001010000 '{}' ';'" % dir,
         "(cd %s && zip -Xqr ../%s *)" % (dir, ctx.outputs.zip.basename),
     ]
-    ctx.action(
-        inputs = list(transitive_jar_set) + list(source_jars) + ctx.files._jdk,
+    ctx.actions.run_shell(
+        inputs = transitive_jar_set.to_list() + source_jars.to_list() + ctx.files._jdk,
         outputs = [zip_output],
         command = " && ".join(cmd),
     )
diff --git a/tools/bzl/js.bzl b/tools/bzl/js.bzl
index e4563a6..28bc0a9 100644
--- a/tools/bzl/js.bzl
+++ b/tools/bzl/js.bzl
@@ -186,7 +186,7 @@
         "zip -Xqr ../%s *" % ctx.outputs.zip.basename,
     ])
 
-    ctx.action(
+    ctx.actions.run_shell(
         inputs = ctx.files.srcs,
         outputs = [ctx.outputs.zip],
         command = cmd,
@@ -256,8 +256,8 @@
     out_zip = ctx.outputs.zip
     out_versions = ctx.outputs.version_json
 
-    ctx.action(
-        inputs = list(zips),
+    ctx.actions.run_shell(
+        inputs = zips.to_list(),
         outputs = [out_zip],
         command = " && ".join([
             "p=$PWD",
@@ -266,7 +266,7 @@
             "rm -rf %s.dir" % out_zip.path,
             "mkdir -p %s.dir/bower_components" % out_zip.path,
             "cd %s.dir/bower_components" % out_zip.path,
-            "for z in %s; do unzip -q $p/$z ; done" % " ".join(sorted([z.path for z in zips])),
+            "for z in %s; do unzip -q $p/$z ; done" % " ".join(sorted([z.path for z in zips.to_list()])),
             "cd ..",
             "find . -exec touch -t 198001010000 '{}' ';'",
             "zip -Xqr $p/%s bower_components/*" % out_zip.path,
@@ -274,11 +274,11 @@
         mnemonic = "BowerCombine",
     )
 
-    ctx.action(
-        inputs = list(versions),
+    ctx.actions.run_shell(
+        inputs = versions.to_list(),
         outputs = [out_versions],
         mnemonic = "BowerVersions",
-        command = "(echo '{' ; for j in  %s ; do cat $j; echo ',' ; done ; echo \\\"\\\":\\\"\\\"; echo '}') > %s" % (" ".join([v.path for v in versions]), out_versions.path),
+        command = "(echo '{' ; for j in  %s ; do cat $j; echo ',' ; done ; echo \\\"\\\":\\\"\\\"; echo '}') > %s" % (" ".join([v.path for v in versions.to_list()]), out_versions.path),
     )
 
     return struct(
@@ -351,7 +351,7 @@
         use_default_shell_env = True,
         execution_requirements = {"local": "1"},
     )
-    ctx.action(
+    ctx.actions.run_shell(
         mnemonic = "Vulcanize",
         inputs = [
             ctx.file._run_npm,
@@ -376,7 +376,7 @@
         ctx.outputs.js.path,
     ])
 
-    ctx.action(
+    ctx.actions.run_shell(
         mnemonic = "Crisper",
         inputs = [
             ctx.file._run_npm,
@@ -426,4 +426,4 @@
 
 def vulcanize(*args, **kwargs):
     """Vulcanize runs vulcanize and crisper on a set of sources."""
-    _vulcanize_rule(*args, pkg = native.package_name(), **kwargs)
+    _vulcanize_rule(pkg = native.package_name(), *args, **kwargs)
diff --git a/tools/bzl/junit.bzl b/tools/bzl/junit.bzl
index ba3b966..f816889 100644
--- a/tools/bzl/junit.bzl
+++ b/tools/bzl/junit.bzl
@@ -50,7 +50,7 @@
     classes = ",".join(
         [_AsClassName(x) for x in ctx.attr.srcs],
     )
-    ctx.file_action(output = ctx.outputs.out, content = _OUTPUT % (
+    ctx.actions.write(output = ctx.outputs.out, content = _OUTPUT % (
         classes,
         ctx.attr.outname,
     ))
diff --git a/tools/bzl/pkg_war.bzl b/tools/bzl/pkg_war.bzl
index 3bf56af..1142a55 100644
--- a/tools/bzl/pkg_war.bzl
+++ b/tools/bzl/pkg_war.bzl
@@ -82,7 +82,7 @@
         elif hasattr(l, "files"):
             transitive_lib_deps += l.files
 
-    for dep in transitive_lib_deps:
+    for dep in transitive_lib_deps.to_list():
         cmd += _add_file(dep, build_output + "/WEB-INF/lib/")
         inputs.append(dep)
 
@@ -91,7 +91,7 @@
     for l in ctx.attr.pgmlibs:
         transitive_pgmlib_deps += l.java.transitive_runtime_deps
 
-    for dep in transitive_pgmlib_deps:
+    for dep in transitive_pgmlib_deps.to_list():
         if dep not in inputs:
             cmd += _add_file(dep, build_output + "/WEB-INF/pgm-lib/")
             inputs.append(dep)
@@ -104,14 +104,14 @@
                 transitive_context_deps += jar.java.transitive_runtime_deps
             elif hasattr(jar, "files"):
                 transitive_context_deps += jar.files
-    for dep in transitive_context_deps:
+    for dep in transitive_context_deps.to_list():
         cmd += _add_context(dep, build_output)
         inputs.append(dep)
 
     # Add zip war
     cmd.append(_make_war(build_output, war))
 
-    ctx.action(
+    ctx.actions.run_shell(
         inputs = inputs,
         outputs = [war],
         mnemonic = "WAR",
diff --git a/tools/eclipse/BUILD b/tools/eclipse/BUILD
index 7e48c7f..e9eb1c7 100644
--- a/tools/eclipse/BUILD
+++ b/tools/eclipse/BUILD
@@ -1,5 +1,5 @@
-load("//tools/bzl:pkg_war.bzl", "LIBS", "PGMLIBS")
 load("//tools/bzl:classpath.bzl", "classpath_collector")
+load("//tools/bzl:pkg_war.bzl", "LIBS", "PGMLIBS")
 load(
     "//tools/bzl:plugins.bzl",
     "CORE_PLUGINS",