From 3452604d50a6638650a8d9fbc94f9287c8731269 Mon Sep 17 00:00:00 2001 From: marcohu Date: Fri, 17 Jan 2020 23:06:13 +0100 Subject: [PATCH] Remove depencency on Java 11, fixes #8 --- .bazelrc | 1 + src/it/java/org/antlr/bazel/BUILD | 19 ++++++++++++++----- src/main/java/org/antlr/bazel/AntlrRules.java | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .bazelrc diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..cb9dfc1 --- /dev/null +++ b/.bazelrc @@ -0,0 +1 @@ +build --javacopt="--release 8" diff --git a/src/it/java/org/antlr/bazel/BUILD b/src/it/java/org/antlr/bazel/BUILD index cc5faec..1064c49 100644 --- a/src/it/java/org/antlr/bazel/BUILD +++ b/src/it/java/org/antlr/bazel/BUILD @@ -1,18 +1,23 @@ load("@rules_java//java:defs.bzl", "java_library") load("//tools:gen_test_rules.bzl", "java_tests") -filegroup( +java_library( name = "support", srcs = glob( ["*.java"], exclude = ["*Test.java"], ), + javacopts = ["--release 11"], + deps = [ + "//src/test/java/org/antlr/bazel:tests", + "@junit//jar", + ], ) java_library( name = "antlr2_tests", testonly = True, - srcs = glob(["Antlr2Test.java"]) + [":support"], + srcs = glob(["Antlr2Test.java"]), data = [ "//:srcs", "//antlr:srcs", @@ -22,6 +27,7 @@ java_library( "@examples//antlr2:srcs", ], deps = [ + ":support", "//src/main/java/org/antlr/bazel", "//src/test/java/org/antlr/bazel:tests", "@antlr2//jar", @@ -41,7 +47,7 @@ java_tests( java_library( name = "antlr3_tests", testonly = True, - srcs = glob(["Antlr3Test.java"]) + [":support"], + srcs = glob(["Antlr3Test.java"]), data = [ "//:srcs", "//antlr:srcs", @@ -50,6 +56,7 @@ java_library( "@examples//antlr3:srcs", ], deps = [ + ":support", "//src/main/java/org/antlr/bazel", "//src/test/java/org/antlr/bazel:tests", "@antlr3_runtime//jar", @@ -71,7 +78,7 @@ java_tests( java_library( name = "antlr4_tests", testonly = True, - srcs = glob(["Antlr4Test.java"]) + [":support"], + srcs = glob(["Antlr4Test.java"]), data = [ "//:srcs", "//antlr:srcs", @@ -80,6 +87,7 @@ java_library( "@examples//antlr4:srcs", ], deps = [ + ":support", "//src/main/java/org/antlr/bazel", "//src/test/java/org/antlr/bazel:tests", "@antlr3_runtime//jar", @@ -103,7 +111,7 @@ java_tests( java_library( name = "repository_tests", testonly = True, - srcs = glob(["RepositoriesTest.java"]) + [":support"], + srcs = glob(["RepositoriesTest.java"]), data = [ "//:srcs", "//antlr:srcs", @@ -113,6 +121,7 @@ java_library( "@examples//antlr2:srcs", ], deps = [ + ":support", "//src/main/java/org/antlr/bazel", "//src/test/java/org/antlr/bazel:tests", "@antlr2//jar", diff --git a/src/main/java/org/antlr/bazel/AntlrRules.java b/src/main/java/org/antlr/bazel/AntlrRules.java index 7f0e7d4..165cf6a 100644 --- a/src/main/java/org/antlr/bazel/AntlrRules.java +++ b/src/main/java/org/antlr/bazel/AntlrRules.java @@ -417,7 +417,7 @@ AntlrRules outputDirectory(String directory) AntlrRules srcjar(String srcjar) { this.srcjar = sandbox.resolve(srcjar); - this.output = srcjar.isBlank() ? Output.FOLDER : Output.SRCJAR; + this.output = srcjar.trim().isEmpty() ? Output.FOLDER : Output.SRCJAR; return this; }