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

Support --incompatible_allow_tags_propagation in native JavaResourceJar actions #25033

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Silic0nS0ldier
Copy link
Contributor

@Silic0nS0ldier Silic0nS0ldier commented Jan 23, 2025

This fixes a bug where tags were not being propagated to JavaResourceJar actions (e.g. java_test(.., resources = ["foo"], ...) like with other native rule actions when --incompatible_allow_tags_propagation is provided.

Relates to #8004

This was tested with the following test case (tests are improved in #25050, no test case has been added for this specific coverage gap).

function test_java_test_tags_propagated_2() {
  mkdir -p test
  cat > test/BUILD <<EOF
package(default_visibility = ["//visibility:public"])
java_test(
  name = "test",
  test_class = "HelloTest",
  srcs = [ "HelloTests.java" ],
  main_class = 'HelloTests',
  tags = ["no-cache", "no-remote", "local"],
  resources = [
      "HelloTests.java",
  ],
)
EOF

	cat > test/HelloTests.java <<EOF
public class HelloTests {
  public void HelloTest(String[] args) {
    System.out.println("Hello there");
  }
}
EOF

  bazel aquery --incompatible_allow_tags_propagation '//test:test' > output1 2> $TEST_log \
      || fail "should have generated output successfully"

  assert_contains_n "Command Line:" 7 output1
  assert_contains_n "local:" 6 output1
  assert_contains_n "no-cache:" 6 output1
  assert_contains_n "no-remote:" 6 output1
}

Before:

action 'Building Java resource jar'
  Mnemonic: JavaResourceJar
  Target: //test:test
  Configuration: k8-fastbuild
  Execution platform: @@platforms//host:host
  ActionKey: 3b749c8811bd0c61168241c1eefd8db5808251fb8c16c45a663c3154d451485a
  Inputs: [bazel-out/k8-fastbuild/bin/test/test-class.jar, external/rules_java++toolchains+remote_java_tools_linux/java_tools/src/tools/singlejar/singlejar_local, test/HelloTests.java]
  Outputs: [bazel-out/k8-fastbuild/bin/test/test.jar]
  Command Line: (exec external/rules_java++toolchains+remote_java_tools_linux/java_tools/src/tools/singlejar/singlejar_local \
    --normalize \
    --dont_change_compression \
    --exclude_build_data \
    --output \
    bazel-out/k8-fastbuild/bin/test/test.jar \
    --sources \
    bazel-out/k8-fastbuild/bin/test/test-class.jar \
    --resources \
    test/HelloTests.java)
# Configuration: a5841cb06d135209cf0f6770d4ead3790474db9531abbac3a35bd81172c0e7ad
# Execution platform: @@platforms//host:host
  ExecutionInfo: {supports-path-mapping: 1}

After:

action 'Building Java resource jar'
  Mnemonic: JavaResourceJar
  Target: //test:test
  Configuration: k8-fastbuild
  Execution platform: @@platforms//host:host
  ActionKey: 684d899f9fe3fd972719c0b7ddcd7bd752265b2d746fbbe89c4b35092f2a7073
  Inputs: [bazel-out/k8-fastbuild/bin/test/test-class.jar, external/rules_java++toolchains+remote_java_tools_linux/java_tools/src/tools/singlejar/singlejar_local, test/HelloTests.java]
  Outputs: [bazel-out/k8-fastbuild/bin/test/test.jar]
  Command Line: (exec external/rules_java++toolchains+remote_java_tools_linux/java_tools/src/tools/singlejar/singlejar_local \
    --normalize \
    --dont_change_compression \
    --exclude_build_data \
    --output \
    bazel-out/k8-fastbuild/bin/test/test.jar \
    --sources \
    bazel-out/k8-fastbuild/bin/test/test-class.jar \
    --resources \
    test/HelloTests.java)
# Configuration: a5841cb06d135209cf0f6770d4ead3790474db9531abbac3a35bd81172c0e7ad
# Execution platform: @@platforms//host:host
  ExecutionInfo: {local: '', no-cache: '', no-remote: '', supports-path-mapping: 1}

@github-actions github-actions bot added team-Rules-Java Issues for Java rules awaiting-review PR is awaiting review from an assigned reviewer labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review PR is awaiting review from an assigned reviewer team-Rules-Java Issues for Java rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant