Skip to content

Commit

Permalink
Disable generated src jar collection by experiment
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 601900893
  • Loading branch information
Googler authored and copybara-github committed Jan 27, 2024
1 parent 9814713 commit b93027f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 15 additions & 1 deletion aspect/build_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def _collect_dependencies_impl(target, ctx):
ctx.attr.exclude,
ctx.attr.always_build_rules,
ctx.attr.generate_aidl_classes,
ctx.attr.use_generated_srcjars,
test_mode = False,
)

Expand All @@ -176,6 +177,7 @@ def _collect_all_dependencies_for_tests_impl(target, ctx):
exclude = None,
always_build_rules = ALWAYS_BUILD_RULES,
generate_aidl_classes = None,
use_generated_srcjars = False,
test_mode = True,
)

Expand Down Expand Up @@ -217,6 +219,7 @@ def _collect_own_java_artifacts(
dependency_infos,
always_build_rules,
generate_aidl_classes,
use_generated_srcjars,
target_is_within_project_scope):
rule = ctx.rule

Expand Down Expand Up @@ -283,7 +286,7 @@ def _collect_own_java_artifacts(
if JavaInfo in target:
for java_output in target[JavaInfo].java_outputs:
# Prefer source jars if they exist:
if java_output.generated_source_jar:
if use_generated_srcjars and java_output.generated_source_jar:
own_gensrc_files.append(java_output.generated_source_jar)
elif java_output.generated_class_jar:
generated_class_jars.append(java_output.generated_class_jar)
Expand Down Expand Up @@ -340,13 +343,15 @@ def _collect_own_and_dependency_java_artifacts(
dependency_infos,
always_build_rules,
generate_aidl_classes,
use_generated_srcjars,
target_is_within_project_scope):
own_files = _collect_own_java_artifacts(
target,
ctx,
dependency_infos,
always_build_rules,
generate_aidl_classes,
use_generated_srcjars,
target_is_within_project_scope,
)

Expand Down Expand Up @@ -443,6 +448,7 @@ def _collect_dependencies_core_impl(
exclude,
always_build_rules,
generate_aidl_classes,
use_generated_srcjars,
test_mode):
dep_infos = _collect_java_dependencies_core_impl(
target,
Expand All @@ -451,6 +457,7 @@ def _collect_dependencies_core_impl(
exclude,
always_build_rules,
generate_aidl_classes,
use_generated_srcjars,
test_mode,
)
if CcInfo in target:
Expand All @@ -466,6 +473,7 @@ def _collect_java_dependencies_core_impl(
exclude,
always_build_rules,
generate_aidl_classes,
use_generated_srcjars,
test_mode):
target_is_within_project_scope = _target_within_project_scope(str(target.label), include, exclude) and not test_mode
dependency_infos = _get_followed_java_dependency_infos(ctx.rule)
Expand All @@ -476,6 +484,7 @@ def _collect_java_dependencies_core_impl(
dependency_infos,
always_build_rules,
generate_aidl_classes,
use_generated_srcjars,
target_is_within_project_scope,
)

Expand All @@ -487,6 +496,7 @@ def _collect_java_dependencies_core_impl(
dependency_infos,
always_build_rules,
generate_aidl_classes,
use_generated_srcjars,
target_is_within_project_scope = True,
)
test_mode_own_files = struct(
Expand Down Expand Up @@ -722,6 +732,10 @@ collect_dependencies = aspect(
doc = "If True, generates classes for aidl files included as source for the project targets",
default = False,
),
"use_generated_srcjars": attr.bool(
doc = "If True, collects generated source jars for a target instead of compiled jar",
default = False,
),
"_build_zip": attr.label(
allow_files = True,
cfg = "exec",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public class BazelDependencyBuilder implements DependencyBuilder {
public static final BoolExperiment fetchArtifactInfoInParallel =
new BoolExperiment("qsync.parallel.artifact.info.fetch", true);

public static final BoolExperiment buildGeneratedSrcJars =
new BoolExperiment("qsync.build.generated.src.jars", false);

/**
* Logs message if the number of artifact info files fetched is greater than
* FILE_NUMBER_LOG_THRESHOLD
Expand Down Expand Up @@ -178,6 +181,10 @@ public OutputInfo build(
.addBlazeFlags(
String.format("--aspects_parameters=always_build_rules=%s", alwaysBuildParam))
.addBlazeFlags("--aspects_parameters=generate_aidl_classes=True")
.addBlazeFlags(
String.format(
"--aspects_parameters=use_generated_srcjars=%s",
buildGeneratedSrcJars.getValue() ? "True" : "False"))
.addBlazeFlags("--noexperimental_run_validations")
.addBlazeFlags("--keep_going");
outputGroups.stream()
Expand Down

0 comments on commit b93027f

Please sign in to comment.