Skip to content

Commit

Permalink
Prepare to remove support for resource_jars
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 221051445
  • Loading branch information
cushon authored and Copybara-Service committed Nov 12, 2018
1 parent 492ac0a commit d559ebd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,11 @@ public JavaTargetAttributes.Builder initCommon(
}

if (ruleContext.attributes().has("resource_jars", BuildType.LABEL_LIST)) {
if (ruleContext.getFragment(JavaConfiguration.class).disallowResourceJars()) {
ruleContext.attributeError(
"resource_jars",
"resource_jars are not supported; use java_import and deps or runtime_deps instead.");
}
javaTargetAttributes.addResourceJars(
PrerequisiteArtifacts.nestedSet(ruleContext, "resource_jars", Mode.TARGET));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public boolean alwaysGenerateOutputMapping() {
private final boolean jplPropagateCcLinkParamsStore;
private final ImmutableList<Label> pluginList;
private final boolean requireJavaToolchainHeaderCompilerDirect;
private final boolean disallowResourceJars;

// TODO(dmarting): remove once we have a proper solution for #2539
private final boolean useLegacyBazelJavaTest;
Expand Down Expand Up @@ -203,6 +204,7 @@ public boolean alwaysGenerateOutputMapping() {
this.explicitJavaTestDeps = javaOptions.explicitJavaTestDeps;
this.experimentalTestRunner = javaOptions.experimentalTestRunner;
this.jplPropagateCcLinkParamsStore = javaOptions.jplPropagateCcLinkParamsStore;
this.disallowResourceJars = javaOptions.disallowResourceJars;

ImmutableList.Builder<Label> translationsBuilder = ImmutableList.builder();
for (String s : javaOptions.translationTargets) {
Expand Down Expand Up @@ -429,4 +431,8 @@ public List<Label> getPlugins() {
public boolean requireJavaToolchainHeaderCompilerDirect() {
return requireJavaToolchainHeaderCompilerDirect;
}

public boolean disallowResourceJars() {
return disallowResourceJars;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,19 @@ public ImportDepsCheckingLevelConverter() {
+ "--java_header_compilation is enabled.")
public boolean requireJavaToolchainHeaderCompilerDirect;

@Option(
name = "incompatible_disallow_resource_jars",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"Disables the resource_jars attribute; use java_import and deps or runtime_deps instead.")
public boolean disallowResourceJars;

private Label getHostJavaBase() {
if (hostJavaBase == null) {
if (useJDK10AsHostJavaBase) {
Expand Down Expand Up @@ -615,9 +628,10 @@ public FragmentOptions getHost() {

host.jplPropagateCcLinkParamsStore = jplPropagateCcLinkParamsStore;


host.requireJavaToolchainHeaderCompilerDirect = requireJavaToolchainHeaderCompilerDirect;

host.disallowResourceJars = disallowResourceJars;

return host;
}

Expand Down

0 comments on commit d559ebd

Please sign in to comment.