Skip to content

Commit eb454bd

Browse files
Bor Kae HwangAndre Rocha
authored andcommitted
Use skylib path is_absolute (bazel-contrib#982)
1 parent 2441739 commit eb454bd

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

scala/private/rule_impls.bzl

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
"""Rules for supporting the Scala language."""
1515

16+
load("@bazel_skylib//lib:paths.bzl", "paths")
1617
load(
1718
"@io_bazel_rules_scala//scala/private:coverage_replacements_provider.bzl",
1819
_coverage_replacements_provider = "coverage_replacements_provider",
@@ -229,25 +230,12 @@ DiagnosticsFile: {diagnostics_output}
229230
diagnostics_file = diagnosticsfile,
230231
)
231232

232-
def _path_is_absolute(path):
233-
# Returns true for absolute path in Linux/Mac (i.e., '/') or Windows (i.e.,
234-
# 'X:\' or 'X:/' where 'X' is a letter), false otherwise.
235-
if len(path) >= 1 and path[0] == "/":
236-
return True
237-
if len(path) >= 3 and \
238-
path[0].isalpha() and \
239-
path[1] == ":" and \
240-
(path[2] == "/" or path[2] == "\\"):
241-
return True
242-
243-
return False
244-
245233
def runfiles_root(ctx):
246234
return "${TEST_SRCDIR}/%s" % ctx.workspace_name
247235

248236
def java_bin(ctx):
249237
java_path = str(ctx.attr._java_runtime[java_common.JavaRuntimeInfo].java_executable_runfiles_path)
250-
if _path_is_absolute(java_path):
238+
if paths.is_absolute(java_path):
251239
javabin = java_path
252240
else:
253241
runfiles_root_var = runfiles_root(ctx)

0 commit comments

Comments
 (0)