Skip to content

Commit 77dd867

Browse files
authored
Remove genrules where possible (#7424)
* Use copy_file from Skylib to copy files. * Simplified no_mockito_extensions without changing its function.
1 parent cd9ff65 commit 77dd867

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

MODULE.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ http_archive(
503503
)
504504

505505
_JARJAR_BUILD_FILE = """
506+
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
507+
506508
java_binary(
507509
name = "jarjar_bin",
508510
srcs = glob(
@@ -525,11 +527,10 @@ java_import(
525527
jars = glob(["lib/asm-*.jar"]),
526528
)
527529
528-
genrule(
530+
copy_file(
529531
name = "help",
530-
srcs = ["src/main/com/tonicsystems/jarjar/help.txt"],
531-
outs = ["com/tonicsystems/jarjar/help.txt"],
532-
cmd = "cp $< $@",
532+
src = "src/main/com/tonicsystems/jarjar/help.txt",
533+
out = "com/tonicsystems/jarjar/help.txt",
533534
)
534535
"""
535536

aspect/BUILD

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Description: Bazel aspect bundled with the Bazel IntelliJ plugin.
33
#
44

5+
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
56
load(":flag_hack.bzl", "define_flag_hack")
67
load(":build_defs.bzl", "aspect_library", "aspect_files")
78

@@ -74,11 +75,11 @@ aspect_library(
7475
# BUILD file bundled with the aspect must not override the BUILD file
7576
# used for development. So we name it BUILD.aspect, and rename prior
7677
# to bundling with the plugin.
77-
genrule(
78+
79+
copy_file(
7880
name = "rename_files",
79-
srcs = ["BUILD.aspect"],
80-
outs = ["BUILD.bazel"],
81-
cmd = "cp $< $@",
81+
src = "BUILD.aspect",
82+
out = "BUILD.bazel",
8283
)
8384

8485
_dev_aspect_path = package_name()

aspect/testing/rules/intellij_aspect_test_fixture.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Rules for writing tests for the IntelliJ aspect."""
22

3+
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
34
load(
45
"//aspect:intellij_info.bzl",
56
"intellij_info_aspect",
@@ -76,9 +77,8 @@ def intellij_aspect_test_fixture(name, deps, transitive_configs = []):
7677

7778
def test_sources(outs):
7879
for out in outs:
79-
native.genrule(
80+
copy_file(
8081
name = out + ".genrule",
81-
srcs = [out + ".testdata"],
82-
outs = [out],
83-
cmd = "cp $< $@",
82+
src = out + ".testdata",
83+
out = out,
8484
)

aswb/testdata/projects/src_transform/BUILD

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
12
load(
23
"//aswb/testdata/projects:test_projects.bzl",
34
"test_project_package",
@@ -26,10 +27,9 @@ java_library(
2627
],
2728
)
2829

29-
genrule(
30+
copy_file(
3031
name = "transformed_source",
31-
srcs = ["java/com/example/TestClass.java"],
32-
outs = ["gen/com/example/TestClass.java"],
33-
cmd = "cp $< $@",
32+
src = "java/com/example/TestClass.java",
33+
out = "gen/com/example/TestClass.java",
3434
tags = ["ij-ignore-source-transform"],
3535
)

intellij_platform_sdk/build_defs.bzl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,9 @@ def no_mockito_extensions(name, jars, **kwargs):
368368
srcs = [input_jar],
369369
outs = [output_jar],
370370
cmd = """
371-
cp "$<" "$@"
372-
chmod u+w "$@"
373371
tmpdir=$$(mktemp -d)
374372
zipper="$$(pwd)/$(execpath @bazel_tools//tools/zip:zipper)"
375-
"$$zipper" x "$@" -d ".out"
373+
"$$zipper" x "$<" -d ".out"
376374
mv ".out" "$$tmpdir"
377375
378376
pushd "$$tmpdir/.out" >/dev/null

0 commit comments

Comments
 (0)