Skip to content

Commit

Permalink
Run buildifier over the repo. No logical changes (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Feb 27, 2021
1 parent 82fca1f commit d0104e3
Show file tree
Hide file tree
Showing 27 changed files with 741 additions and 535 deletions.
6 changes: 3 additions & 3 deletions BUILD
Expand Up @@ -33,6 +33,9 @@ stardoc(
bzl_library(
name = "implementation",
srcs = [
":coursier.bzl",
":defs.bzl",
":specs.bzl",
"//:private/coursier_utilities.bzl",
"//:private/dependency_tree_parser.bzl",
"//:private/proxy.bzl",
Expand All @@ -48,9 +51,6 @@ bzl_library(
"//private/rules:pom_file.bzl",
"//settings:stamp_manifest.bzl",
"//third_party/bazel_json/lib:json_parser.bzl",
":coursier.bzl",
":defs.bzl",
":specs.bzl",
],
)

Expand Down
19 changes: 9 additions & 10 deletions WORKSPACE
Expand Up @@ -62,7 +62,6 @@ rules_jvm_external_setup()
# Begin test dependencies

load("//:defs.bzl", "maven_install")

load("//:specs.bzl", "maven")

maven_install(
Expand Down Expand Up @@ -165,7 +164,7 @@ maven_install(
"com.google.guava:guava:27.0-jre",
"javax.inject:javax.inject:1",
"org.apache.beam:beam-sdks-java-core:2.15.0",
"org.bouncycastle:bcprov-jdk15on:1.64"
"org.bouncycastle:bcprov-jdk15on:1.64",
],
maven_install_json = "//tests/custom_maven_install:manifest_stamp_testing_install.json",
repositories = [
Expand Down Expand Up @@ -329,12 +328,12 @@ maven_install(
"com.typesafe.play:play_2.11:2.5.19",
"org.scalatestplus.play:scalatestplus-play_2.11:2.0.1",
],
fetch_sources = True,
repositories = [
"https://repo1.maven.org/maven2",
],
version_conflict_policy = "pinned",
fetch_sources = True,
use_unsafe_shared_cache = True,
version_conflict_policy = "pinned",
)

maven_install(
Expand All @@ -344,11 +343,11 @@ maven_install(
"com.android.support:appcompat-v7:28.0.0",
"com.android.support:swiperefreshlayout:28.0.0",
],
jetify = True,
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
jetify = True,
)

maven_install(
Expand All @@ -358,14 +357,14 @@ maven_install(
"com.android.support:appcompat-v7:28.0.0",
"com.android.support:swiperefreshlayout:28.0.0",
],
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
jetify = True,
jetify_include_list = [
"com.android.support:appcompat-v7",
],
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
)

# https://github.com/bazelbuild/rules_jvm_external/issues/351
Expand All @@ -376,12 +375,12 @@ maven_install(
"io.quarkus:quarkus-maven-plugin:1.0.1.Final",
"io.quarkus:quarkus-bom-descriptor-json:1.0.1.Final",
],
fetch_sources = True,
maven_install_json = "//tests/custom_maven_install:json_artifacts_testing_install.json",
repositories = [
"https://repo.maven.apache.org/maven2/",
"https://repo.spring.io/plugins-release/",
],
fetch_sources = True,
)

# https://github.com/bazelbuild/rules_jvm_external/issues/433
Expand Down
33 changes: 21 additions & 12 deletions coursier.bzl
Expand Up @@ -192,6 +192,7 @@ def compute_dependency_inputs_signature(artifacts):
artifact_inputs = []
for artifact in artifacts:
parsed = json_parse(artifact)

# Sort the keys to provide a stable order
keys = sorted(parsed.keys())
flattened = ":".join(["%s=%s" % (key, parsed[key]) for key in keys])
Expand Down Expand Up @@ -278,7 +279,7 @@ def get_home_netrc_contents(repository_ctx):
return ""

def _get_jq_http_files():
'''Returns repository targets for the `jq` dependency that `pin.sh` needs.'''
"""Returns repository targets for the `jq` dependency that `pin.sh` needs."""
lines = []
for jq in JQ_VERSIONS:
lines.extend([
Expand Down Expand Up @@ -384,7 +385,7 @@ def _pinned_coursier_fetch_impl(repository_ctx):
"or:\n" +
" 1) Set 'fail_if_repin_required' to 'False' in 'maven_install'\n" +
" 2) Run 'bazel run @unpinned_%s//:pin'\n" % repository_ctx.name +
" 3) Reset 'fail_if_repin_required' to 'True' in 'maven_install'\n\n");
" 3) Reset 'fail_if_repin_required' to 'True' in 'maven_install'\n\n")
else:
print("The inputs to %s_install.json have changed, but the lock file has not been regenerated. " % repository_ctx.name +
"Consider running 'bazel run @unpinned_%s//:pin'" % repository_ctx.name)
Expand Down Expand Up @@ -525,8 +526,8 @@ def remove_auth_from_url(url):
host = url_parts[0]
if "@" not in host:
return url
last_index=host.rfind("@", 0, None)
userless_host=host[last_index + 1:]
last_index = host.rfind("@", 0, None)
userless_host = host[last_index + 1:]
new_url = "{}://{}".format(protocol, "/".join([userless_host] + url_parts[1:]))
return new_url

Expand Down Expand Up @@ -612,8 +613,7 @@ def make_coursier_dep_tree(
fetch_javadoc,
use_unsafe_shared_cache,
timeout,
report_progress_prefix="",
):
report_progress_prefix = ""):
# Set up artifact exclusion, if any. From coursier fetch --help:
#
# Path to the local exclusion file. Syntax: <org:name>--<org:name>. `--` means minus. Example file content:
Expand Down Expand Up @@ -681,18 +681,23 @@ def make_coursier_dep_tree(

repository_ctx.report_progress(
"%sResolving and fetching the transitive closure of %s artifact(s).." % (
report_progress_prefix, len(artifact_coordinates)))
report_progress_prefix,
len(artifact_coordinates),
),
)

exec_result = repository_ctx.execute(
cmd,
timeout = timeout,
environment = environment,
quiet = not _is_verbose(repository_ctx))
quiet = not _is_verbose(repository_ctx),
)
if (exec_result.return_code != 0):
fail("Error while fetching artifact with coursier: " + exec_result.stderr)

return _deduplicate_artifacts(json_parse(repository_ctx.read(repository_ctx.path(
"dep-tree.json"))))
"dep-tree.json",
))))

def _download_jq(repository_ctx):
jq_version = None
Expand Down Expand Up @@ -720,12 +725,14 @@ def _coursier_fetch_impl(repository_ctx):

# Try running coursier once
cmd = _generate_java_jar_command(repository_ctx, repository_ctx.path("coursier"))

# Add --help because calling the default coursier command on Windows will
# hang waiting for input
cmd.append("--help")
exec_result = repository_ctx.execute(
cmd,
quiet = not _is_verbose(repository_ctx))
quiet = not _is_verbose(repository_ctx),
)
if exec_result.return_code != 0:
fail("Unable to run coursier: " + exec_result.stderr)

Expand Down Expand Up @@ -816,7 +823,7 @@ def _coursier_fetch_impl(repository_ctx):
coord_split = artifact["coord"].split(":")
coord_unversioned = "{}:{}".format(coord_split[0], coord_split[1])
should_jetify = jetify_all or (repository_ctx.attr.jetify and coord_unversioned in jetify_include_dict)
if should_jetify :
if should_jetify:
artifact["directDependencies"] = jetify_artifact_dependencies(artifact["directDependencies"])
artifact["dependencies"] = jetify_artifact_dependencies(artifact["dependencies"])

Expand Down Expand Up @@ -888,7 +895,8 @@ def _coursier_fetch_impl(repository_ctx):
)
exec_result = repository_ctx.execute(
hasher_command + ["--argsfile", repository_ctx.path("hasher_argsfile")],
quiet = not _is_verbose(repository_ctx))
quiet = not _is_verbose(repository_ctx),
)
if exec_result.return_code != 0:
fail("Error while obtaining the sha256 checksums: " + exec_result.stderr)

Expand Down Expand Up @@ -938,6 +946,7 @@ def _coursier_fetch_impl(repository_ctx):
outdated_build_file_content = ""
else:
repository_name = repository_ctx.name

# Add outdated artifact files if this is a pinned repo
outdated_build_file_content = _BUILD_OUTDATED
_add_outdated_files(repository_ctx, artifacts, repositories)
Expand Down
1 change: 0 additions & 1 deletion examples/android_kotlin_app/WORKSPACE
Expand Up @@ -6,7 +6,6 @@ android_sdk_repository(
build_tools_version = "28.0.2",
)


# BEGIN io_bazel_rules_kotlin

RULES_KOTLIN_VERSION = "9051eb053f9c958440603d557316a6e9fda14687"
Expand Down
1 change: 0 additions & 1 deletion examples/android_local_test/WORKSPACE
Expand Up @@ -6,7 +6,6 @@ android_sdk_repository(
build_tools_version = "28.0.2",
)


http_archive(
name = "robolectric",
sha256 = "2ee850ca521288db72b0dedb9ecbda55b64d11c470435a882f8daf615091253d",
Expand Down
1 change: 0 additions & 1 deletion examples/simple/WORKSPACE
Expand Up @@ -4,7 +4,6 @@ android_sdk_repository(
build_tools_version = "28.0.2",
)


local_repository(
name = "rules_jvm_external",
path = "../../",
Expand Down
8 changes: 5 additions & 3 deletions private/dependency_tree_parser.bzl
Expand Up @@ -103,14 +103,16 @@ def _generate_imports(repository_ctx, dep_tree, explicit_artifacts, neverlink_ar
elif repository_ctx.attr.fetch_javadoc and get_classifier(artifact["coord"]) == "javadoc":
seen_imports[target_label] = True
all_imports.append(
"filegroup(\n\tname = \"%s\",\n\tsrcs = [\"%s\"],\n\ttags = [\"javadoc\"],\n)" % (target_label, artifact_path))
"filegroup(\n\tname = \"%s\",\n\tsrcs = [\"%s\"],\n\ttags = [\"javadoc\"],\n)" % (target_label, artifact_path),
)
elif get_packaging(artifact["coord"]) == "json":
seen_imports[target_label] = True
versioned_target_alias_label = "%s_extension" % escape(artifact["coord"])
all_imports.append(
"alias(\n\tname = \"%s\",\n\tactual = \"%s\",\n\tvisibility = [\"//visibility:public\"],\n)" % (target_label, versioned_target_alias_label))
"alias(\n\tname = \"%s\",\n\tactual = \"%s\",\n\tvisibility = [\"//visibility:public\"],\n)" % (target_label, versioned_target_alias_label),
)
if repository_ctx.attr.maven_install_json:
all_imports.append(_genrule_copy_artifact_from_http_file(artifact))
all_imports.append(_genrule_copy_artifact_from_http_file(artifact))
elif target_label in labels_to_override:
# Override target labels with the user provided mapping, instead of generating
# a jvm_import/aar_import based on information in dep_tree.
Expand Down
24 changes: 12 additions & 12 deletions private/rules/javadoc.bzl
Expand Up @@ -30,21 +30,21 @@ javadoc = rule(
_javadoc_impl,
doc = "Generate a javadoc from all the `deps`",
attrs = {
"deps": attr.label_list(
doc = """The java libraries to generate javadocs for.
"deps": attr.label_list(
doc = """The java libraries to generate javadocs for.
The source jars of each dep will be used to generate the javadocs.
Currently docs for transitive dependencies are not generated.
""",
mandatory = True,
providers = [
[JavaInfo],
],
),
"_javadoc": attr.label(
default = "//private/tools/java/rules/jvm/external/javadoc",
cfg = "host",
executable = True,
),
mandatory = True,
providers = [
[JavaInfo],
],
),
"_javadoc": attr.label(
default = "//private/tools/java/rules/jvm/external/javadoc",
cfg = "host",
executable = True,
),
},
)

0 comments on commit d0104e3

Please sign in to comment.