Skip to content

Commit

Permalink
Use validation actions for[]
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 469282079
Change-Id: If78552b1b3fb347b648dc265c677ccb08d4a2267
  • Loading branch information
cushon authored and Copybara-Service committed Aug 22, 2022
1 parent a7697af commit b0e2cf7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ public ConfiguredTarget create(RuleContext ruleContext)
AndroidFeatureFlagSetProvider.getAndValidateFlagMapFromRuleContext(ruleContext);

if (oneVersionOutputArtifact != null) {
builder.addOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL, oneVersionOutputArtifact);
builder.addOutputGroup(
javaConfig.enforceOneVersionValidationAction()
? OutputGroupInfo.VALIDATION
: OutputGroupInfo.HIDDEN_TOP_LEVEL,
oneVersionOutputArtifact);
}

NestedSet<Artifact> extraFilesToRun =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ public ConfiguredTarget create(RuleContext ruleContext)
// of safety.)
if (javaConfig.enforceOneVersionOnJavaTests() || !isJavaTestRule(ruleContext)) {
builder.addOutputGroup(
OutputGroupInfo.HIDDEN_TOP_LEVEL,
javaConfig.enforceOneVersionValidationAction()
? OutputGroupInfo.VALIDATION
: OutputGroupInfo.HIDDEN_TOP_LEVEL,
OneVersionCheckActionBuilder.newBuilder()
.withEnforcementLevel(javaConfig.oneVersionEnforcementLevel())
.outputArtifact(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public enum ImportDepsCheckingLevel {
private final boolean isDisallowStrictDepsForJpl;
private final OneVersionEnforcementLevel enforceOneVersion;
private final boolean enforceOneVersionOnJavaTests;
private final boolean enforceOneVersionValidationAction;
private final ImportDepsCheckingLevel importDepsCheckingLevel;
private final boolean allowRuntimeDepsOnNeverLink;
private final JavaClasspathMode javaClasspath;
Expand Down Expand Up @@ -139,6 +140,7 @@ public JavaConfiguration(BuildOptions buildOptions) throws InvalidConfigurationE
this.isDisallowStrictDepsForJpl = javaOptions.isDisallowStrictDepsForJpl;
this.enforceOneVersion = javaOptions.enforceOneVersion;
this.enforceOneVersionOnJavaTests = javaOptions.enforceOneVersionOnJavaTests;
this.enforceOneVersionValidationAction = javaOptions.enforceOneVersionValidationAction;
this.importDepsCheckingLevel = javaOptions.importDepsCheckingLevel;
this.allowRuntimeDepsOnNeverLink = javaOptions.allowRuntimeDepsOnNeverLink;
this.explicitJavaTestDeps = javaOptions.explicitJavaTestDeps;
Expand Down Expand Up @@ -394,6 +396,10 @@ public boolean enforceOneVersionOnJavaTests() {
return enforceOneVersionOnJavaTests;
}

public boolean enforceOneVersionValidationAction() {
return enforceOneVersionValidationAction;
}

public ImportDepsCheckingLevel getImportDepsCheckingLevel() {
return importDepsCheckingLevel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,16 @@ public ImportDepsCheckingLevelConverter() {
+ " violations.")
public boolean enforceOneVersionOnJavaTests;

@Option(
name = "experimental_one_version_enforcement_validation_action",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
help =
"When enabled, and with experimental_one_version_enforcement set to a non-NONE value,"
+ " enforce one version using validation actions.")
public boolean enforceOneVersionValidationAction;

@Option(
name = "experimental_allow_runtime_deps_on_neverlink",
defaultValue = "true",
Expand Down Expand Up @@ -645,6 +655,7 @@ public FragmentOptions getHost() {
host.importDepsCheckingLevel = importDepsCheckingLevel;
// java_test targets can be used as a host tool, Ex: as a validating tool on a genrule.
host.enforceOneVersionOnJavaTests = enforceOneVersionOnJavaTests;
host.enforceOneVersionValidationAction = enforceOneVersionValidationAction;
host.allowRuntimeDepsOnNeverLink = allowRuntimeDepsOnNeverLink;
host.addTestSupportToCompileTimeDeps = addTestSupportToCompileTimeDeps;

Expand Down

0 comments on commit b0e2cf7

Please sign in to comment.