Skip to content

Commit

Permalink
Use multiple URLs for external downloads
Browse files Browse the repository at this point in the history
This bumps the Bazel requirement to 0.4.2

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=141521907
  • Loading branch information
jart committed Dec 9, 2016
1 parent 4ee0d52 commit a47cc06
Show file tree
Hide file tree
Showing 24 changed files with 568 additions and 390 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ os:
- osx

env:
- V=HEAD
- V=0.4.0
- V=0.3.2
- V=0.4.2

before_install:
- |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ JavaScript | Templating | Stylesheets | Miscellaneous
[closure_js_deps] | [closure_py_template_library] | |
[closure_js_test] | | |

Bazel ≥0.3.2 | linux-x86_64 | ubuntu_15.10-x86_64 | darwin-x86_64
Bazel ≥0.4.2 | linux-x86_64 | ubuntu_15.10-x86_64 | darwin-x86_64
:---: | :---: | :---: | :---:
[![Build Status](https://travis-ci.org/bazelbuild/rules_closure.svg?branch=master)](https://travis-ci.org/bazelbuild/rules_closure) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_closure/BAZEL_VERSION=latest,PLATFORM_NAME=linux-x86_64)](http://ci.bazel.io/job/rules_closure/BAZEL_VERSION=latest,PLATFORM_NAME=linux-x86_64) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_closure/BAZEL_VERSION=latest,PLATFORM_NAME=ubuntu_15.10-x86_64)](http://ci.bazel.io/job/rules_closure/BAZEL_VERSION=latest,PLATFORM_NAME=ubuntu_15.10-x86_64) | [![Build Status](http://ci.bazel.io/buildStatus/icon?job=rules_closure/BAZEL_VERSION=latest,PLATFORM_NAME=darwin-x86_64)](http://ci.bazel.io/job/rules_closure/BAZEL_VERSION=latest,PLATFORM_NAME=darwin-x86_64)

Expand Down Expand Up @@ -922,7 +922,7 @@ This rule can be referenced as though it were the following:

- **defs:** (List of strings; optional) Specifies additional flags to be passed
to the Closure Stylesheets compiler. To see what flags are available, run:
`bazel run @io_bazel_rules_closure//third_party/java/csscomp:ClosureCommandLineCompiler`
`bazel run @io_bazel_rules_closure@closure_stylesheets//:ClosureCommandLineCompiler`


## closure\_js\_proto\_library
Expand Down
94 changes: 63 additions & 31 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,54 +1,86 @@
workspace(name = "io_bazel_rules_closure")

load("//closure/private:java_import_external.bzl", "java_import_external")
load("//closure:repositories.bzl", "closure_repositories")

closure_repositories()

maven_jar(
java_import_external(
name = "guava_testlib",
artifact = "com.google.guava:guava-testlib:19.0",
server = "closure_maven_server",
sha1 = "ce5b880b206de3f76d364988a6308c68c726f74a",
jar_sha256 = "a9f52f328ac024e420c8995a107ea0dbef3fc169ddf97b3426e634f28d6b3663",
jar_urls = [
"http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/guava/guava-testlib/20.0/guava-testlib-20.0.jar",
"http://repo1.maven.org/maven2/com/google/guava/guava-testlib/20.0/guava-testlib-20.0.jar",
"http://maven.ibiblio.org/maven2/com/google/guava/guava-testlib/20.0/guava-testlib-20.0.jar",
],
licenses = ["notice"], # Apache 2.0
testonly_ = 1,
deps = ["@guava"],
)

maven_jar(
java_import_external(
name = "jimfs",
artifact = "com.google.jimfs:jimfs:1.1",
server = "closure_maven_server",
sha1 = "8fbd0579dc68aba6186935cc1bee21d2f3e7ec1c",
jar_sha256 = "c4828e28d7c0a930af9387510b3bada7daa5c04d7c25a75c7b8b081f1c257ddd",
jar_urls = [
"http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar",
"http://repo1.maven.org/maven2/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar",
"http://maven.ibiblio.org/maven2/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar",
],
licenses = ["notice"], # Apache 2.0
testonly_ = 1,
deps = ["@guava"],
)

maven_jar(
java_import_external(
name = "junit",
artifact = "junit:junit:4.11",
server = "closure_maven_server",
sha1 = "4e031bb61df09069aeb2bffb4019e7a5034a4ee0",
jar_sha256 = "90a8e1603eeca48e7e879f3afbc9560715322985f39a274f6f6070b43f9d06fe",
jar_urls = [
"http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/junit/junit/4.11/junit-4.11.jar",
"http://repo1.maven.org/maven2/junit/junit/4.11/junit-4.11.jar",
"http://maven.ibiblio.org/maven2/junit/junit/4.11/junit-4.11.jar",
],
licenses = ["reciprocal"], # Common Public License 1.0
testonly_ = 1,
deps = ["@hamcrest_core"],
)

maven_jar(
java_import_external(
name = "hamcrest_core",
artifact = "org.hamcrest:hamcrest-core:1.3",
server = "closure_maven_server",
sha1 = "42a25dc3219429f0e5d060061f71acb49bf010a0",
jar_sha256 = "66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9",
jar_urls = [
"http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar",
"http://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar",
"http://maven.ibiblio.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar",
],
licenses = ["notice"], # BSD
testonly_ = 1,
)

maven_jar(
name = "hamcrest_library",
artifact = "org.hamcrest:hamcrest-library:1.3",
server = "closure_maven_server",
sha1 = "4785a3c21320980282f9f33d0d1264a69040538f",
)

maven_jar(
java_import_external(
name = "mockito",
artifact = "org.mockito:mockito-all:1.10.19",
server = "closure_maven_server",
sha1 = "539df70269cc254a58cccc5d8e43286b4a73bf30",
jar_sha256 = "d1a7a7ef14b3db5c0fc3e0a63a81b374b510afe85add9f7984b97911f4c70605",
jar_urls = [
"http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.jar",
"http://repo1.maven.org/maven2/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.jar",
"http://maven.ibiblio.org/maven2/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.jar",
],
licenses = ["notice"], # MIT
testonly_ = 1,
deps = [
"@hamcrest_core",
"@junit",
],
)

maven_jar(
java_import_external(
name = "truth",
artifact = "com.google.truth:truth:0.28",
server = "closure_maven_server",
sha1 = "0a388c7877c845ff4b8e19689dda5ac9d34622c4",
jar_sha256 = "1037ded3a681c74ce020e306f136b24a51c09c95667d8eda9ffc8f8136294f71",
jar_urls = [
"http://bazel-mirror.storage.googleapis.com/repo1.maven.org/maven2/com/google/truth/truth/0.28/truth-0.28.jar",
"http://repo1.maven.org/maven2/com/google/truth/truth/0.28/truth-0.28.jar",
"http://maven.ibiblio.org/maven2/com/google/truth/truth/0.28/truth-0.28.jar",
],
licenses = ["notice"], # Apache 2.0
testonly_ = 1,
deps = ["@guava"],
)
7 changes: 7 additions & 0 deletions closure/compiler/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@
package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

java_library(
name = "compiler",
exports = [
"@closure_compiler",
],
)
60 changes: 60 additions & 0 deletions closure/private/java_import_external.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2016 The Closure Rules 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.

def _java_import_external(repository_ctx):
"""Downloads jar and creates a java_import rule."""
urls = repository_ctx.attr.jar_urls
sha256 = repository_ctx.attr.jar_sha256
basename = urls[0][urls[0].rindex('/') + 1:]
lines = [
"# DO NOT EDIT: automatically generated BUILD file",
"",
"package(default_visibility=[\"//visibility:public\"])",
"",
"licenses(%s)" % repr(repository_ctx.attr.licenses),
"",
"java_import(",
" name = %s," % repr(repository_ctx.name),
" jars = [%s]," % repr(basename),
]
for attr in ("deps",
"runtime_deps",
"exports",
"neverlink",
"visibility"):
value = getattr(repository_ctx.attr, attr, None)
if value:
lines.append(" %s = %s," % (attr, repr(value)))
if repository_ctx.attr.testonly_:
lines.append(" testonly = 1,")
lines.append(")")
lines.append("")
if repository_ctx.attr.extra:
lines.append(repository_ctx.attr.extra)
repository_ctx.download(urls, basename, sha256)
repository_ctx.file("BUILD", "\n".join(lines))

java_import_external = repository_rule(
implementation=_java_import_external,
attrs={
"jar_urls": attr.string_list(mandatory=True, allow_empty=False),
"jar_sha256": attr.string(mandatory=True),
"licenses": attr.string_list(mandatory=True),
"deps": attr.string_list(),
"runtime_deps": attr.string_list(),
"exports": attr.string_list(),
"neverlink": attr.bool(),
"testonly_": attr.bool(),
"extra": attr.string(),
})
2 changes: 1 addition & 1 deletion closure/private/java_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def java_proto_library(name, src, testonly=None, visibility=None, **kwargs):
native.java_library(
name = name,
srcs = [":%s_srcjar" % name],
deps = ["@protobuf_java//jar"],
deps = ["@protobuf_java"],
javacopts = ["-Xlint:-rawtypes"],
testonly = testonly,
visibility = visibility,
Expand Down
12 changes: 6 additions & 6 deletions closure/private/platform_http_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

def _impl(repository_ctx):
if repository_ctx.os.name.lower().startswith('mac os'):
url = repository_ctx.attr.macos_url
urls = repository_ctx.attr.macos_urls
sha256 = repository_ctx.attr.macos_sha256
else:
url = repository_ctx.attr.amd64_url
urls = repository_ctx.attr.amd64_urls
sha256 = repository_ctx.attr.amd64_sha256
basename = url[url.rindex('/') + 1:]
repository_ctx.download(url, basename, sha256)
basename = urls[0][urls[0].rindex('/') + 1:]
repository_ctx.download(urls, basename, sha256)
repository_ctx.symlink(basename, "file/" + basename)
repository_ctx.file("file/BUILD", "\n".join([
("# DO NOT EDIT: automatically generated BUILD file for " +
Expand All @@ -37,8 +37,8 @@ def _impl(repository_ctx):
platform_http_file = repository_rule(
implementation=_impl,
attrs={
"amd64_url": attr.string(),
"amd64_urls": attr.string_list(),
"amd64_sha256": attr.string(),
"macos_url": attr.string(),
"macos_urls": attr.string_list(),
"macos_sha256": attr.string(),
})
Loading

0 comments on commit a47cc06

Please sign in to comment.