Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rules_java to a more recent version #613

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions closure/compiler/closure_js_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def _closure_js_library_impl(
includes = (),
exports = depset(),
deps_stylesheets = [],
exports_stylesheets = [],
internal_descriptors = depset(),
no_closure_library = False,
internal_expect_failure = False,
Expand Down Expand Up @@ -396,7 +395,6 @@ def _closure_js_library(ctx):
getattr(ctx.attr, "includes", []),
extract_providers(ctx.attr.exports, ClosureJsLibraryInfo),
extract_providers(ctx.attr.deps, ClosureCssLibraryInfo),
extract_providers(ctx.attr.exports, ClosureCssLibraryInfo),
ctx.files.internal_descriptors,
ctx.attr.no_closure_library,
ctx.attr.internal_expect_failure,
Expand Down
12 changes: 5 additions & 7 deletions closure/private/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def get_jsfile_path(f):
def extract_providers(deps, provider):
return [dep[provider] for dep in deps if provider in dep]

def unfurl(deps, provider = ""):
def unfurl(deps):
"""Returns deps as well as deps exported by parent rules."""
res = []
for dep in deps:
Expand Down Expand Up @@ -198,14 +198,12 @@ def collect_css(deps, orientation = None):
srcs = []
labels = []
for dep in deps:
if hasattr(dep[ClosureCssLibraryInfo], "srcs"):
srcs.append(getattr(dep[ClosureCssLibraryInfo], "srcs"))
if hasattr(dep[ClosureCssLibraryInfo], "labels"):
labels.append(getattr(dep[ClosureCssLibraryInfo], "labels"))
srcs.append(getattr(dep, "srcs", []))
labels.append(getattr(dep, "labels", []))
if orientation:
if dep[ClosureCssLibraryInfo].orientation != orientation:
if dep.orientation != orientation:
fail("%s does not have the same orientation" % dep.label)
orientation = dep[ClosureCssLibraryInfo].orientation
orientation = dep.orientation
return struct(
srcs = depset(transitive = srcs),
labels = depset(transitive = labels),
Expand Down
7 changes: 3 additions & 4 deletions closure/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1038,11 +1038,10 @@ def rules_cc():
def rules_java():
http_archive(
name = "rules_java",
sha256 = "f5a3e477e579231fca27bf202bb0e8fbe4fc6339d63b38ccb87c2760b533d1c3",
strip_prefix = "rules_java-981f06c3d2bd10225e85209904090eb7b5fb26bd",
sha256 = "29ba147c583aaf5d211686029842c5278e12aaea86f66bd4a9eb5e525b7f2701",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz",
"https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/releases/download/6.3.0/rules_java-6.3.0.tar.gz",
"https://github.com/bazelbuild/rules_java/releases/download/6.3.0/rules_java-6.3.0.tar.gz",
],
)

Expand Down
3 changes: 2 additions & 1 deletion closure/stylesheets/closure_css_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ load(
"ClosureCssLibraryInfo",
"collect_css",
"collect_runfiles",
"extract_providers",
"unfurl",
)

def _closure_css_binary(ctx):
if not ctx.attr.deps:
fail("closure_css_binary rules can not have an empty 'deps' list")
deps = unfurl(ctx.attr.deps, provider = ClosureCssLibraryInfo)
deps = unfurl(extract_providers(ctx.attr.deps, provider = ClosureCssLibraryInfo))
css = collect_css(deps)
if not css.srcs:
fail("There are no CSS source files in the transitive closure")
Expand Down
6 changes: 4 additions & 2 deletions closure/stylesheets/closure_css_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ load(
"ClosureJsLibraryInfo",
"collect_css",
"collect_runfiles",
"extract_providers",
"unfurl",
)

def _closure_css_library(ctx):
deps = unfurl(ctx.attr.deps, provider = ClosureCssLibraryInfo)
deps = unfurl(extract_providers(ctx.attr.deps, provider = ClosureCssLibraryInfo))
exports = unfurl(extract_providers(ctx.attr.exports, provider = ClosureCssLibraryInfo))
css = collect_css(deps, ctx.attr.orientation)
return [
ClosureCssLibraryInfo(
label = ctx.label,
srcs = depset(ctx.files.srcs, transitive = [css.srcs]),
labels = depset([ctx.label], transitive = [css.labels]),
orientation = ctx.attr.orientation,
exports = unfurl(ctx.attr.exports),
exports = exports,
),
ClosureJsLibraryInfo(),
DefaultInfo(
Expand Down
6 changes: 3 additions & 3 deletions closure/templates/closure_js_template_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

load("//closure/compiler:closure_js_aspect.bzl", "closure_js_aspect")
load("//closure/compiler:closure_js_library.bzl", "closure_js_library")
load("//closure/private:defs.bzl", "ClosureJsLibraryInfo", "SOY_FILE_TYPE", "unfurl")
load("//closure/private:defs.bzl", "ClosureJsLibraryInfo", "SOY_FILE_TYPE", "extract_providers", "unfurl")
load("//closure/templates:closure_templates_plugin.bzl", "SoyPluginInfo")

_SOYTOJSSRCCOMPILER = "@com_google_template_soy//:SoyToJsSrcCompiler"
Expand Down Expand Up @@ -47,8 +47,8 @@ def _impl(ctx):
if ctx.file.globals:
args += ["--compileTimeGlobalsFile", ctx.file.globals.path]
inputs.append(ctx.file.globals)
for dep in unfurl(ctx.attr.deps, provider = ClosureJsLibraryInfo):
for f in dep[ClosureJsLibraryInfo].descriptors.to_list():
for dep in unfurl(extract_providers(ctx.attr.deps, provider = ClosureJsLibraryInfo)):
for f in dep.descriptors.to_list():
args.append("--protoFileDescriptors=%s" % f.path)
inputs.append(f)

Expand Down
3 changes: 2 additions & 1 deletion closure/testing/phantomjs_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ load(
"ClosureJsLibraryInfo",
"HTML_FILE_TYPE",
"collect_runfiles",
"extract_providers",
"long_path",
"unfurl",
)
Expand All @@ -33,7 +34,7 @@ def _impl(ctx):
files = [ctx.outputs.executable]
srcs = []
direct_srcs = []
deps = unfurl(ctx.attr.deps, provider = ClosureJsLibraryInfo)
deps = list(ctx.attr.deps)
for dep in deps:
if ClosureJsBinaryInfo in dep:
direct_srcs.append(dep[ClosureJsBinaryInfo].bin)
Expand Down
7 changes: 2 additions & 5 deletions java/io/bazel/rules/closure/testing/TestDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

/** The test driver that triggers test running on the browser and collects test results. */
public class TestDriver {

private static final Logger logger = Logger.getLogger(TestDriver.class.getName());
private static final long POLL_INTERVAL = 100;
private static final long TEST_TIMEOUT = 300;
Expand All @@ -51,9 +50,8 @@ public boolean run() {
new FluentWait<>((JavascriptExecutor) driver)
.pollingEvery(Duration.ofMillis(POLL_INTERVAL))
.withTimeout(Duration.ofSeconds(TEST_TIMEOUT))
.until(
executor -> (boolean) executor.executeScript("return window.top.G_testRunner.isFinished()")
);
.until(executor
-> (boolean) executor.executeScript("return window.top.G_testRunner.isFinished()"));
} catch (TimeoutException e) {
logger.log(Level.SEVERE, String.format("Test timeout after %s seconds", TEST_TIMEOUT));
return false;
Expand All @@ -77,4 +75,3 @@ public void quit() {
driver.quit();
}
}